0

At this moment I am at products/index page, I have set up layout so now at the left side I have menu where I can choose between multiple categories. These are links, so when I click on them I am redirected to categories controller with specific categegory.

But I wan't to just render category controllers action show with specific category. Is that possible, I need just a tip, I don't need full answer :)

Thanks

Edgars
  • 913
  • 1
  • 19
  • 53
  • 1
    what you want to implement actually..? as soon as click on category link, it will go to categories#index method. And you want to render products#index view.. right..? – Jyothu Jul 10 '13 at 08:12
  • @Jyothu I wan't to implement that clicking on left menu would render partial on that same products controller. Partial would consist of other controller data, such subcategories. At the menu I can choose Product categories, clicking that would render subcategories of the main category at the same page, but now I have like, clicking on menu redirects to different controller. – Edgars Jul 10 '13 at 08:18

3 Answers3

1

in side bar

<%= link_to products_path(:category => cat.id) %>

in products#index

@category = Category.find params[:category]

in products/index.html.erb

<% render '/categories/category' if @category.present? %>
rhernando
  • 1,051
  • 7
  • 18
0

Couldn't find Category without an ID Its because off the this metod that generates link_to these categories, how can I merge this kind off functionallity ?

<ul id="menuks">

<li id="auctions">Atkritumu pārstrādes tehnika</li> <% @children1.each do |o|%> <li class="submenuks"> <%= link_to (o.name), o %></li> <%end%>

</ul>

Edgars
  • 913
  • 1
  • 19
  • 53
0

Thanks to @rhernando I found solution.

Controller

@category = Category.find_by_name(params[:category])

Side menu

<li id="auctions">Atkritumu pārstrādes tehnika</li>
<% @children1.each do |o|%>
    <li class="submenuks"> <%= link_to (o.name), products_path(:category => o.name) %></li>
    <%end%>
Edgars
  • 913
  • 1
  • 19
  • 53