Reputation: 8597
I have two different controllers I got from rails generate, and each controller has index, edit, update, destroy, etc...
Now I'm trying to relate these two controllers (lists and ideas). I have this loop in my lists -> show page
<% @list.ideas.each do |idea| %>
<div>
<div class="list_idea_desc"><%= idea.description %></div>
<div><%= link_to 'Show', idea %></div>
<div><%= link_to 'Edit', edit_idea_path(idea) %></div>
<div><%= link_to 'Destroy', idea, method: :delete, data: { confirm: 'Are you sure?' } %></div>
</div>
<% end %>
I'm trying to get the edit_idea_path
to work, but it gives me error
No route matches {:action=>"edit", :controller=>"ideas",
:id=>#<Idea id: nil, name: nil, description: nil, picture: nil,
created_at: nil, updated_at: nil, list_id: 2>}
Any idea how I can use the two different controllers? Does this give enough information?
Thanks
Upvotes: 0
Views: 521
Reputation: 89
check your routes.rb file as you are using RESTful routing
and if not help, paste the routes code here
Upvotes: 0
Reputation: 62698
Your Idea
instance doesn't have an ID (:id=>#<Idea id: nil...
), so the router can't generate a route for it. Make sure your Ideas are saved before attempting to generate yours for them.
Also, not directly related to the problem, but you can just use link_to "Edit", [:edit, idea]
to have it infer the route based on the class of idea
.
Upvotes: 1