Ruby on Rails Tuesday, March 1, 2011

Hello,

I'd like to have the main menu of my web application dynamically
generated from categories stored in a database.

I created a partial for this menu:
(views/category/_list.html.erb)

<ul>
<% @categories.each do |category| %>
<li><%= category.name %></li>
<% end %>
</ul>


And I call this partial in the main layout:
(layouts/application.html.erb):

<%= render 'category/list' %>

Unfortunately, the @categories variable is Nil because the category/list
controller is not called with this method.

How can I simply achieve this ? Thank you,

Fabrice

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment