ruby on rails - Using a form_for to create a nested model row -
- Each "user" has a "move"
- Many in each "swap" "Neighborhood Preferences".
I want to create a form on the "/ user / (: id) / edit" page, allowing a person to edit "move", and "neighborhood-preferences".
Currently, this form displays correctly, but when I submit the form, I get this error move (# 2168853040) Expected, ActionController :: parameter (# 2158484920) < / Code> found.
How can I save both a new step and neighborhood / priorities?
View # Edit for users
& lt;% = form_for (@user) | F | & Gt%; & Lt;% = hidden_field_tag "user [step] [neighborhood_iodes] []", zero%> & Lt;% @ neighborhoods.each do | N | & Gt%; & Lt;% = check_box_tag "User [location] [neighborhood_idus] []", NID, # user @ move.neighborhood_ids.include submit to value (n.id), # Check the box on the Load ID: dom_id (n ) Add a unique category based on # objects & gt; & Lt;% = label_tag dom_id (n), n.name% & gt; & Lt; Br / & gt; & Lt;% end% & gt; & Lt;% = f.submit "Save Changes"% & gt; & Lt;% end% & gt;
Controller # Edit for user
edit def = user = user.fund (param [: id]) @ neighbors = neighborhood. Private DEF User_params params.require (: user) .permit (: Email ,: Age, Gender :: University, Graduate, Business:, Company, # Allow user to deposit neighborhood_ID for the move. Go ahead: [ Neighborhood_ID: []] end
model
class user & lt; ActiveRecord :: Base # attr_accessible: Provider,: UID ,: name,: email validated_presence_of: name is_one: move Acceptpts_nested_attributes_for: move, allow_destroy: true class Move & lt; ActiveRecord :: Base is_to: User has_many: Neighborhood_preferences has_many: Neighborhood, via: Neighborhood_preferences accept___nested_attributes_for: neighborhood_preferences, allow_destroy: true end class NeighbhoodPreference & lt; ActiveRecord :: Base is_to: neighborhood is_to: move end
Comments
Post a Comment