Displaying 2 results from an estimated 2 matches for "timesheet_id".
2013 Mar 25
1
validates presence of foreign key fails in nested form
...ble :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, presence: true, uniqueness: { scope: ''timesheet_id''}
belongs_to :timesheet
belongs_to :task
has_many :time_entries, order: :workdate, dependent: :destroy
accepts_nested_attributes_for :time_entries, allow_destroy: true,
rej...
2013 Mar 04
2
accepts_nested_attributes: undefined method 'association'_attributes
...:status, :user_id, :time_entries_attributes
has_many :time_entries, dependent: :destroy
accepts_nested_attributes_for :time_entries, :reject_if => proc {
|attributes| attributes[''worktime''].blank? }
end
class TimeEntry < ActiveRecord::Base
attr_accessible :task_id, :timesheet_id, :workdate, :worktime
belongs_to :timesheet
end
As explained in Rails API:
```
Using with attr_accessible
The use of attr_accessible can interfere with nested attributes if you’re
not careful. For example, if the Member model above was using
attr_accessible like this:
attr_accessible :n...