문제

Ok guys so I have a nested route like this:

resources :apps do
    resources :forms
end

In my form index I have this block:

<% @forms.each do |form| %>
  <tr>
    <td><%= form.app_id %></td>
    <td><%= form.title %></td>
    <td><%= link_to 'Show', app_form(@app,form) %></td>
    <td><%= link_to 'Destroy', form, :confirm => 'Are you sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>

The page throws a NoMethodError on the app_form line; however I think I am passing in the app and form in correctly (I've also tried to pass in the @app.id). Calling rake routes... the route is even displayed:

app_form GET    /apps/:app_id/forms/:id(.:format)      {:controller=>"forms", :action=>"show"}

Any help would be greatly appreciated!

도움이 되었습니까?

해결책

Try app_form_path(@app, form) instead (you need to append _path to the route name).

다른 팁

Not only nested routes,For each routes you using, You need to append _path or _url with route name.
So here juz try app_form_path(@app,form) or app_form_url(@app,form)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top