for whatever reason, isn't saving. give me success , redirect page supposed page_id on group item nil.
<%= simple_form_for group |f| %> <%= f.input :page_id, collection: @pages, selected: group.page, label: false %> <%= f.button :submit, "assign page" %> <% end %>
controller
def update group = group.find(params[:id]) group.update_attributes(group_params) redirect_to groups_path, notice: "did it" end
and params (i have tried every variation on could). odd bit here, form seems creating nested param.
def group_params params.require(:group).permit(:name, :page, :group => [:page_id]) end
the returned request params:
{"utf8"=>"✓", "_method"=>"patch", "authenticity_token"=>"cccccii383838=", "group"=>{"page_id"=>"2"}, "commit"=>"assign page", "action"=>"update", "controller"=>"groups", "id"=>"3"}
a group has_one page. page has_one group. associated ids on each of models.
any thoughts? i'm banging head against wall silly problem.
did try ? think problem group_params
method
def group_params params.require(:group).permit(:page_id) end
Comments
Post a Comment