forms - Rails: Unable to route to edit page when a new nested item fails validation -
i have nested item creation form lies in show view of parent. in case single achievement (achievement_item) on achievements list (achievement).
everything seems work except new items fail validation. error thrown up:
routing error
no route matches {:action=>"show", :controller=>"achievements"}
try running
rake routes
more information on available routes.
when run rake routes
forest of information. aside, should looking for? compared "show" actions of achievements , achievement_items counterparts in photo_galleries , gallery_photos (a structure got working - redirects invalid new gallery_photos edit page - i've been comparing of files side side, haven't found logical differences, isn't there aren't any), looks has same format.
i don't know begin. i'm going in controller of nested item:
def create @achievement = achievement.find(params[:achievement_id]) @achievement_item = @achievement.achievement_items.create(params[:achievement_item]) if @achievement_item.save redirect_to achievement_path(@achievement) else render "edit" end end
commenting out render "edit"
causes missing template error, @ least know i'm hitting line.
here edit page:
<h1>editing achievement item</h1> <%= render 'form', achievement_item: @achievement_item %> <%= link_to 'show', @achievement %> | <%= link_to 'back', achievement_path %>
it nice if such error message point toward problem is. , somebody should problems. :-)
banging out question made me find answer. in hopes saves somebody few hours of frustration, here is:
in edit page of nested item:
<%= link_to 'back', achievements_path %>
that's it. a missing plural on link wasn't using led hours of frustration.
Comments
Post a Comment