Displaying 1 result from an estimated 1 matches for "active_plan".
Did you mean:
active_flag
2009 Jul 15
0
has_many and has_one ... and nested form
...to cleanly do the following:
- I have model User
- User has many Plans
- User has one Active Plan
- New User form has fields on it to create the Active Parent
I want to create a new User with an Active Plan in one form.
At the moment I have:
class User < ActiveRecord::Base
has_one :active_plan, :class_name => ''Plan'', :conditions =>
[''active = ?'', true]
has_many :plans
def active_plan_attributes=(attributes)
plans.build(attributes.merge(:active => true))
end
end
So that in the form I can wrap the active plan fields in:
<% f.fields_f...