Displaying 1 result from an estimated 1 matches for "active_plan_attributes".
2009 Jul 15
0
has_many and has_one ... and nested form
...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_for :active_plan, @active_plan do |ap| %>
...
<% end %>
The @active_plan is being set in the user controller new action atm.
Is this the c...