If you usually sort by the same field, you can define a method <=>(and optionally include Comparable) in the model and just call model.sortit and it should work.
in model:
class Brand < AcvtiveRecord::Base
def <=> other
self.name <=> other.name
end
end
view:
<% @category.brands.sort.each do |brand| %>
<li <%= "class='current'" if brand == @brand %>>
<%= link_to(brand.name, [@category, brand]) %>
</li>
<% end %>
, , , .
( )
@brands = Brand.all.sort
:
<% @brands.each do |brand| %>
<li <%= "class='current'" if brand == @brand %>>
<%= link_to(brand.name, [@category, brand]) %>
</li>
<% end %>