1

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!

3
  • It's generally good to post the error in the problem description. Commented May 19, 2011 at 20:31
  • Like the title I have above? Or something more descriptive? Commented May 20, 2011 at 5:39
  • Generally, the backtrace itself, or at least the first couple lines. I'm glad @dmarkow was able to guess the right answer for you though. Commented May 20, 2011 at 21:25

2 Answers 2

5

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

Sign up to request clarification or add additional context in comments.

Comments

0

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.