ruby - Rails link to a new post in a category without going to the category page -
i have post model , category model. , when in show page of model can create new post belongs category with:
<%= link_to 'new post', new_page_path(:category_id => @category)%>.
however see list of categories this:
<% @categories.each |category| %> <h3><%= link_to category.title, category %></h3> <% end %>
and want clicking on category go directly new post form in category. instead of having go category_show page first.
to direct category link new post form instead of category show page, can change link follows:
<% @categories.each |category| %> <h3><%= link_to category.title, new_page_path(:category_id => category) %></h3> <% end %>
with change, when click on category go directly new post form in category.
Comments
Post a Comment