search for: activities_attribut

Displaying 2 results from an estimated 2 matches for "activities_attribut".

Did you mean: activities_attributes
2013 Mar 25
1
validates presence of foreign key fails in nested form
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 :activities, allow_destroy: true end class Activity < ActiveRecord::Base attr_accessible :task_id, :timesheet_id, :time_entries_attributes validates :task_id, presenc...
2013 Mar 26
0
nested forms: use validate :some_method works in update mode only
...when updating the same record the validation gets it right but continues to catch the error even after modifying the needed attribute value to make it pass. Here is the model: #timesheet.rb class Timesheet < ActiveRecord::Base attr_accessible :status, :user_id, :start_date, :end_date, :activities_attributes SUBMITTED = ''Submitted'' APPROUVED = ''Approuved'' REJECTED = ''Rejected'' STATUS_VALUES = [SUBMITTED, APPROUVED, REJECTED] belongs_to :user has_many :activities, dependent: :destroy, inverse_of: :timesheet has_many :time_entrie...