Answer the question
In order to leave comments, you need to log in
How to properly render related objects in Rail 4?
Good day, I can’t understand how to make the correct render, there are posts, the posts have categories,
I registered in the view
<% Category.all.each do |category| %>
<li class="list-group-item"><%= link_to category.name, category_post_path(category_id:category.id) %> </li>
<% end %>
category_posts_path GET /categories/:category_id/posts(.:format) posts#index
POST /categories/:category_id/posts(.:format) posts#create
new_category_post_path GET /categories/:category_id/posts/new(.:format) posts#new
edit_category_post_path GET /categories/:category_id/posts/:id/edit(.:format) posts#edit
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question