map.resources :daily_contents do |daily_content|
daily_content.resources :vocabularies
end
you have to specify a parameter for link_to like this:
<% for vocabulary in @daily_content.vocabularies %>
..
<%= link_to 'Show', [@daily_content, vocabulary] %>
<% end %>
The generated URL is like this:
http://localhost:3000/daily_contents/5/vocabularies/2
Moreover, if @daily_content.entities is just an array, which happens to contain an object of type, Vocabulary, the following works as well:
<% for entity in @daily_content.entities %>
..
<%= link_to 'Show', [@daily_content, entity] %>
<% end %>
Again the generated URL is same as above like:
http://localhost:3000/daily_contents/5/vocabularies/2
No comments:
Post a Comment