Hello EverybodyI have a navigation that draws data from a category table, I would like to display the navigation by category ID order, this is the code I have so far<%= link_to category.title, category_path(category) %> in the viewnot sure where to go next to get order by category idSteven
Thanks Rick
on the actual categories page the categories are listed in category_id order correctly, I have the following code in my controller
# GET /categories# GET /categories.jsondef index@categories = Category.order('id asc')end
The only problem is the navigation list that I have put into the application layout page seems to have a mind of its own, here is the code for
<li class="link"><% Category.all.each do |category| %><%= link_to category.name, category_path(category), :order => ('id desc') %><% end %></li></ul></div></nav>it just displays the list in a random order.
On Tuesday, March 4, 2014 10:25:54 AM UTC, Steven Cahill wrote:Hello Everybody
I have a navigation that draws data from a category table, I would like to display the navigation by category ID order, this is the code I have so far
<%= link_to category.title, category_path(category) %> in the view
not sure where to go next to get order by category id
Steven
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5dce3073-c36a-4b12-a0d2-4a1e2b155835%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Thanks Rickon the actual categories page the categories are listed in category_id order correctly, I have the following code in my controller
# GET /categories# GET /categories.json
def index@categories = Category.order('id asc')end
The only problem is the navigation list that I have put into the application layout page seems to have a mind of its own, here is the code for