I have a many-to-one relationship between a model named Category(one)
and a model named Brands (one). How can I get ActiveRecord to order the
brands by the “name” attribute? This seems like a simple question and I
can think of long ways around it but there has go to be a way to do this
by accessing @category.brands . Can anyone help? I tried the code below
in the controller but it didn’t seem to order the brands in the view
when I accessed @category.brands
@category = Category.find(params[:id])
@category.brands = Brand.find(:all, :conditions => [“category_id = ?”,
params[:id]], :order => “name”)