Why none of the validations work in update mode when using the below model
relation and nested forms:
#timesheet.rb
class Timesheet < ActiveRecord::Base
has_many :activities, dependent: :destroy
has_many :time_entries, through: :activities
validates_associated :activities, length: { minimum: 1 }
validates_presence_of :activities
..
end
#activity.rb
class Activity < ActiveRecord::Base
class Activity < ActiveRecord::Base
attr_accessible :task_id, :timesheet_id, :time_entries_attributes
validates :task_id, presence: true
belongs_to :timesheet
belongs_to :task
has_many :time_entries, order: :workdate, dependent: :destroy
end
If when updating a timesheet I remove an activity, the timesheet will be
updated with no problems instead of raising validation error on activity.
Any idea? Thank you.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/PJECK4p1Q4kJ.
For more options, visit https://groups.google.com/groups/opt_out.