I'm trying to use sort on each do. I get the error
wrong number of arguments(1 for 0)
I understand that I cannot daisy chain them together. Does anyone know another methods of getting this done.
<% Category.sort(:id).limit(4).each do |type| %>
<%= type.name %>
<% end %>
The result I am aiming for is to have all categories listed from a to z.
Assuming the Category
is an Active Record
then
<% Category.order(:id).limit(4).each do |type| %>
<% Category.order(:id).limit(4).each do |type| %>
would do the trick.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.