simple form - Rails 4 action routes with simple_form and shallow nested resources -
resources :users, shallow: true resources :shoes end
this gives me 2 different routes create , edit
user_shoes_path shoes_path
in shoes _form.html.erb
if leave form tag :url default missing routes error when submit new or updated shoe.
if supply url in form can work either new or edit update, can't work both.
this works new:
<%= simple_form_for :shoe, url: user_shoes_path |f| %>
this works edit, fail once tries actual update since redirects /:param_id
:
<%= simple_form_for :shoe, url: shoes_path(@shoe) |f| %>
how can make work both? thanks.
you should use
<% = simple_form_for [@user, @shoe] |f| %>
and let simple_form work...
this case, if there @user, simple form use (as new), if there isn't (like edit), simple form won't use it...
Comments
Post a Comment