Data dodania Pytanie
2017-06-11 00:06 Create ActiveRecord has_one through association »
Given the ActiveRecord models and associations below, I need to add a has_one :owner association on the account model to reference a user whose accoun...
(1) odpowiedzi
2017-06-09 18:06 How to fetch record from deep nested association? »
I'm just starting up with RoR so bare with me if I call things wrong. I have these 3 models for example. Board, Truck, Driver. Here's a sketch of wh...
(3) odpowiedzi
2017-06-08 18:06 How to associate two joining models in ActiveRecord? »
Lets assume we have 2 AR models: class User < ApplicationRecord has_many :proposals has_many :concerns end class Job < ApplicationRecord ...
(1) odpowiedzi
2017-06-07 23:06 Is there a cleaner way to get a hold of an ActiveRecord query interface? »
I have this which works, but I thought there might be a specific method for it. @deals = Deal.where("1=1") if @dealFilter.min.to_i > 0 @de...
(1) odpowiedzi
2017-06-07 07:06 Rails 3.2 : Duplicate entry for key index in mysql? »
I am using rails 3.2. Here! I am facing a problem, stats below. I am having two model classes RequestedTrip and TagTrip. Here! are two other models R...
(1) odpowiedzi
2017-06-07 03:06 Unexpected behavior while in Rails console »
Rails 3.2 I am in a Rails console session, and I am trying to find a company by id. I have a companies tables, with an id column. I did company = C...
(1) odpowiedzi
2017-06-06 16:06 Rails 5: Associated relation triggers create instead of update on edit view »
I started with the guide on http://guides.rubyonrails.org/getting_started.html. I successfully get it up and running. So far I made a few adjustments ...
(1) odpowiedzi
2017-06-06 13:06 How can I disable lazy loading of active record queries? »
I want to query some objects from the database using a WHERE clause similar to the following: @monuments = Monument.where("... lots of SQL ...").lim...
(2) odpowiedzi
2017-06-06 04:06 How do I create a foreign key in rails 5 if I've already created the models for the tables I want to associate? »
All of the references I've found either show me how to do it upon table creation, or are for a much earlier version of rails. Ideally, I'd like like t...
(1) odpowiedzi
2017-06-05 23:06 AR Query for jsonb attribute column »
I'm using Postgres for my db, and I have a column in my Auction model as a jsonb column. I want to create a query that searches the Auction's json col...
(2) odpowiedzi
2017-06-05 19:06 Rails: destroy_all and update has_many size »
I have the following relationship: class Match has_many :players end In one example case, I have a match with 2 players, one with the attribute t...
(1) odpowiedzi
2017-06-05 18:06 Getting activerecord readonly error when adding a where clause »
I have two queries for two different pages: all_teams = Team.includes(:terms, :labs, people: [:schools], term_enrollments: [:lab]) current_teams = Te...
(1) odpowiedzi
2017-05-31 16:05 Ruby on Rails active record - understanding code »
I am very new in coding and Ruby on Rails. There is a website and the part of code below makes the data to be displayed on the website. I need to unde...
(0) odpowiedzi
2017-05-31 08:05 Can I get/access a form_builder.object's ATTRIBUTE in Rails? »
I have resorted to ask a question here since this is something that's puzzling me: I am trying to create a nested attributes form with the following ...
(0) odpowiedzi
2017-05-31 02:05 Renamed belongs_to association, it currently can't find the associated model »
My user.location is returning nil currently. My model looks like: # id # user_location_id class User < ApplicationRecord belongs_to :location, ...
(1) odpowiedzi
2017-05-30 14:05 RubyonRails Not able to save has_many relation »
I have two models industry_matcher and staffroom Model IndustryMatcher class IndustryMatcher < ActiveRecord::Base has_many :industries, cla...
(1) odpowiedzi
2017-05-26 18:05 No route matches [DELETE] "/questions/5/answers" »
Trying to create a delete button, but having some issues with the path. I thought I wrote it correct. Any help and suggestions is well appreciated ...
(2) odpowiedzi
2017-05-26 11:05 Difference between Model.ids and Model.select(:id).map(&:id) »
I have been trying to find the how rails handles call to Model.ids and Model.select(:id).map(&:id) When i try to execute the same in console i se...
(1) odpowiedzi
2017-05-26 04:05 How to perform model validation in rails? »
I have a rails application where Activity is one of the resources with the following attributes: status (recording the status of activity "in progre...
(1) odpowiedzi
2017-05-25 21:05 How can I load Rails fixtures into a different schema »
My Rails 5.0.2 application uses two databases. One is my main application database and the second is accessed in read only mode by my application (a ...
(0) odpowiedzi
2017-05-25 13:05 RoR - Show model linked with a foreign key »
In my app I have Users and Bands. A User can create a Band, so in the database schema, the table Band has a foreign key band_manager_id referred to th...
(1) odpowiedzi
2017-05-25 06:05 How do I implement a common validation method for several attributes in rails »
I have a model with two time attributes as follows, class Notification < ActiveRecord::Base validate :time1_must_be_in_the_past? validate :tim...
(2) odpowiedzi
2017-05-23 21:05 active_recrod_delayed_job is being ignored »
i have used `active_record_delayed_job' before without problem. i added to Gemfile gem 'delayed_job_active_record' rails g delayed_job:active_rec...
(0) odpowiedzi
2017-05-22 16:05 Should I use a denormaized field for amount outstanding in Ruby on Rails »
I have a simple normalized model for invoices and payments. The relevant fields are invoices.id invoices.amount_with_tax invoice_payments.id invo...
(1) odpowiedzi
2017-05-21 17:05 ActiveRecord::StatementInvalid in Controller when using an ActiveRecord with a table name and a postgresql view »
I have an Event which belongs to Repeat and I am trying to display the repeat title when displaying an event. But I do not want two database calls whi...
(1) odpowiedzi
2017-05-21 16:05 Rails: find attachments without user OR without comment »
Attachment has_one :comment, optional: true Attachment has_one :user, through :comment, comment - through task, task - through project I want to fin...
(1) odpowiedzi
2017-05-21 06:05 Is it possible that I can add and remove objects to a ActiveRecordRelation »
I have a situation where I need to concatenate multiple scopes based on time to a single active record relation. I have following model class Featu...
(0) odpowiedzi
2017-05-20 19:05 Query based on attribute's size »
I wonder if it's possible in Rails 5 to do a where query for attributes of given length? Let's say I have a serialized Array attribute called tags on...
(1) odpowiedzi
2017-05-20 14:05 undefined method `xx' for nil:NilClass »
I have two Model class in my ror project. User: class User < ActiveRecord::Base has_many :restaurants end Restaurant class Restaurant &l...
(1) odpowiedzi
2017-05-20 03:05 Defining custom ActiveRecord creators through associations »
I have some models with a has_many and belongs_to associations between them similar to below: class Customer < ActiveRecord::Base # attributes i...
(2) odpowiedzi
2017-05-19 18:05 Rails InvalidForeignKey »
I am developing a portfolio for my website, I decided to add skills to each portfolio item. class PortfolioSkill < ApplicationRecord belongs_to...
(1) odpowiedzi
2017-05-19 05:05 Rails has one association »
I am working on building a portfolio section in my website right now. I have it set where a portfolio has one category that is associated with it. ...
(3) odpowiedzi
2017-05-18 11:05 How to use OR in ActiveRecord Rails 4.1.1? »
I'm used scope where(address: [nil, ''], city: [nil, '']) and I get request WHERE ((`address`.`address` = '' OR `address`.`address` IS NULL) AND (`a...
(2) odpowiedzi
2017-05-17 07:05 rails5&activerecord: how to properly seed&save polymorphic associations »
This ought to be a pretty basic question but I'm stuck right now. I have these models: class Character < ApplicationRecord has_one :inventory, ...
(0) odpowiedzi
2017-05-16 10:05 Rails set has_many value dynamically »
I have an entity: book of class Book. The entity class has has_many relation with other tables, pages for example. Let's say that page_1 and page_2 ...
(2) odpowiedzi