Re: [Rails] validates presence of foreign key fails in nested form

2013-03-25 Thread Serguei Cambour
Found the way to do that by using 'inverse_of' option (see below): On 25 Mar 2013, at 16:03, Javix wrote: > I'm using accepts_nested_attributes as follows: > > class Timesheet < ActiveRecord::Base > attr_accessible :status, :user_id, :start_date, :end_date, > :activities_attributes > has_m

[Rails] validates presence of foreign key fails in nested form

2013-03-25 Thread Javix
I'm using accepts_nested_attributes as follows: class Timesheet < ActiveRecord::Base attr_accessible :status, :user_id, :start_date, :end_date, :activities_attributes has_many :activities, dependent: :destroy has_many :time_entries, through: :activities accepts_nested_attributes_for :acti

[Rails] Validates presence

2011-12-13 Thread JavierQQ
Hi everyone, I just need a quick help :) What is the best way to write some code in :presence option? I have a Question model and one of the fields is question_type: - example question - static question Each question has alternatives, and each of them has scores What I want is to validate th

[Rails] Validates presence of special conditions not working

2010-01-08 Thread Alpha Blue
Here is the validation being used which is not working.. validates_presence_of :name => :controller_name, :if => :redirect?, :message => "must have the same name as the controller." The model has a string field for name. The model has a boolean field for redirect. The model has a string field for