Validates the presence of association when using nested forms

Why none of the validations work in update mode when using the below
relation and nested forms:


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


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

If when updating a timesheet I remove an activity, the timesheet will be
updated with no problems instead of raising validation error on
Any idea? Thank you.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs