Data dodania Pytanie
2017-02-03 19:02 How do I completely avoid using a database in RSpec tests? »
I want to use FactoryGirl to build in-memory stubs of models, then have all ActiveRecord queries run against only those. For example: # Assume we st...
(1) odpowiedzi
2017-02-03 01:02 How to replace model associations in-memory in Rails? »
Let's say I have a Person model, that a Person has many Pets and a Pet has a polymorphic association to Dog and Cat. Note that a person cannot have an...
(2) odpowiedzi
2017-02-02 11:02 Rails app does not sort publications by year »
I have a Rails 5 app with publications. These publications need to be ordered by year, with recent years on top. The years field on a publication has...
(1) odpowiedzi
2017-02-01 23:02 Quering a has_many_through join table in Rails »
I have an app in Rails 5 where I have the following relationships: User model has_many :consult_users has_many :consults, through: :consult_users ...
(1) odpowiedzi
2017-02-01 21:02 Controller / ActiveRecord .where(...NOT IN...) with possible empty in set »
$ ruby -v ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux] $ rails -v Rails 4.2.0 $ grep DESCR /etc/lsb-release DISTRIB_DESCRIPTION="Ubuntu ...
(1) odpowiedzi
2017-02-01 13:02 ActiveRecord::StatementInvalid PG::UndefinedColumn: ERROR »
I am using rails_admin for admin panel. Just change association in Image model From this class Image < ApplicationRecord belongs_to :user ...
(1) odpowiedzi
2017-01-30 13:01 Rails activerecord dup with associations »
I have a scenario where we run a queue to copy all the events. The events has maps, locations associated with it. I'm able to copy the events but it's...
(0) odpowiedzi
2017-01-30 10:01 active job in rails 4 »
I am looking forward to active job for active record for rails 4. I search related to it. I found gem 'delayed_job_active_record' . But this supports ...
(1) odpowiedzi
2017-01-29 03:01 Could not load 'active_record/connection_adapters/mongodb_adapter »
I have created a new rails app by just the command rails new testApp and when i run the server in dev on my local mac with 'rails s' and then visit l...
(0) odpowiedzi
2017-01-27 22:01 How to get the count of unsaved associated records? »
Given these ActiveRecord table definitions: create_table :parents do |t| end create_table :children do |t| t.references :parent end And the corr...
(1) odpowiedzi
2017-01-27 07:01 Update parent and add child in Active Record »
I get a JSON array of records for POST :- My Parent table model is as follows :- class UserVehicle < ApplicationRecord has_many :service_bil...
(2) odpowiedzi
2017-01-26 17:01 Database query for array data type receives error: No operator matches the given name and argument type(s) »
My Tennis Calendar model has a week attribute set as array data type, since tournaments can last two weeks. As an example, the first element is below:...
(1) odpowiedzi
2017-01-25 11:01 Rails Active Record equivalent of SQL with conditional expressions »
I have the following SQL SELECT a, CASE WHEN a=1 THEN 'one' WHEN a=2 THEN 'two' ELSE 'other' END FROM test;...
(1) odpowiedzi
2017-01-25 10:01 Ruby on Rails - Scoping resources by current_account »
I’m new to ruby on rails and I’m a bit stuck with what the best next step is in a multi-tenancy application I’m building. Basically I want to s...
(1) odpowiedzi
2017-01-24 22:01 Rails scope with combined attributes »
I am trying to create a scope where checkin_time (DateTime) is added with duration (Int) in hours which is greater than or equal to Time.now So somet...
(1) odpowiedzi
2017-01-24 22:01 Rails: ActiveRecord using where with a custom comparator »
I have a model called Update which contains column :version which is a string. class Update < ApplicationRecord validates_presence_of :version e...
(2) odpowiedzi
2017-01-24 17:01 How to delete a collection matching a condition »
I would like to delete all posts associated to every user of my application matching a determined condition. In particular I would like to delete all ...
(1) odpowiedzi
2017-01-23 12:01 Rails eager loading associations »
I have two models MSellingStaff and MPosition #m_selling_staff.rb class MSellingStaff < ActiveRecord::Base belongs_to :m_position end #m_posit...
(3) odpowiedzi
2017-01-21 21:01 Rails - Object Available in View, but Not Object's properties? »
I've got an unusual problem where I can access an Object, but not its properties in a view. Any Assistance, guidance, is greatly appreciated. This ...
(2) odpowiedzi
2017-01-21 20:01 Rails with FactoryGirl, parent-child association. Omit creating one more record in child model »
I have two models. Parent model Tag: class Tag < ApplicationRecord has_many :keywords, inverse_of: :tag, dependent: :destroy accepts_nested_at...
(2) odpowiedzi
2017-01-19 14:01 before_remove to abort removal crashes server when throwing exception »
I'm using Rails 5's Association Callbacks. I read in the documentation that if you want to abort an object removal from an association you have to thr...
(1) odpowiedzi
2017-01-17 20:01 `find_or_create_by!` and an `after_initialize` callback »
We have something like: class User < ActiveRecord::Base #... after_initialize do |user| # stuff1 end end User.find_or_create_by!(email:...
(0) odpowiedzi
2017-01-17 13:01 Rails validations with enum »
I have an enum in my Box model enum box_type: [:wooden, :plastic, :metal, :paper] and I want the box_type attribute of my Box model to be only one ...
(1) odpowiedzi
2017-01-15 12:01 Rails Job Doesn't Proceed after rails jobs:work »
I have a job in my rails app which I was running it before like a charm with this command: rails jobs:work but it doesn't proceed any longer.I kill...
(1) odpowiedzi
2017-01-15 11:01 ActiveRecord's serialize converts integers to strings? [Rails] »
When I am persisting a hash as a JSON, I expect the hash to be converted to JSON and not modified, but instead the keys are changed from integer to st...
(2) odpowiedzi
2017-01-13 22:01 Rails 5 ActiveRecord - check if any results before using methods »
In my Rails 5 + Postgres app I make a query like this: user = User.where("name = ?", name).first.email So this gives me the email of the first user...
(3) odpowiedzi
2017-01-12 02:01 How to create a new record using the values from a variable already under the same class »
I remove records all the time to test, and need to re-create the same record to test again. So doing this: User.create(name: "Peter", col1: "etc", ...
(3) odpowiedzi
2017-01-11 23:01 How do I merge parent array and one child with different attribute? »
I have comments and likes (acts_as_votable gem). I want to create one activity list and sort by created_at for comments and updated_at for votes. @ac...
(1) odpowiedzi
2017-01-10 22:01 ActiveRecord Rollback when trying to save to database »
I am building a fairly simple album review application. I am attempting to set up a simple_form for new reviews. The change will not stick. This is wh...
(1) odpowiedzi
2017-01-10 16:01 Ruby on Rails - where query with Time parse »
How can I select all records where the date is past? I have "Date" column with format : '%m/%d/%Y' e.g "01/10/2017". Column type is string, I can't c...
(3) odpowiedzi
2017-01-09 23:01 ActiveRecord read replica for reporting queries »
I have a Rails/ActiveRecord application that occasionally executes some heavy read-only queries against the application's models for ad-hoc admin/repo...
(0) odpowiedzi
2017-01-06 13:01 How to create migration script for has_many, belong_to association between user and task model in ruby »
I have two model User and Task. Task would have one owner and other as workers. class Task < ApplicationRecord belongs_to :user has_many :...
(1) odpowiedzi
2017-01-06 00:01 rails controller find record with no associations »
Student has_many enrollments Is there a way to see only students that have no enrollments? Something like: @students = Student.includes(:enrollmen...
(1) odpowiedzi
2017-01-05 23:01 Rails Active Record Query joins only, any »
Student has_many :enrollments With this query I see those students that have true enrollments, but also those that have both, true and false enrollm...
(1) odpowiedzi
2017-01-05 05:01 Have access to multiple databases »
I am developing an application that at the beginning the user can select which database to connect to. It is a Rails application which uses Active-Rec...
(0) odpowiedzi