Ruby on Rails global categories block -


i new ror , don't understand how can make global template put in other template. example have categories module , create sidebar navigation , put @ homepage template. tried way, categories controller method side_nav never called. practice type of problem or should different way?

categories/categories_controller.rb

def side_nav     @categories = category.all end 

categories/_side_nav.html.erb

<ul class="list-unstyled">   <% categories.each |category| %>     <li><%= link_to category.title, category.title.downcase %></li>   <% end %>  </ul> 

homepage/index.html.erb

<%= render 'categories/side_nav' %> 

you may @ layout/application file. it's global layout in custom project default. , can provide custom layouts in contollers.

http://guides.rubyonrails.org/layouts_and_rendering.html


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -