I have the model
class Article < ActiveRecord::Base
belongs_to :category
end
class Category < ActiveRecord::Base
has_one :article
end
In the controller I am fetching all category names
@categories = Category.order('name')
How could I fetch all categories and sort them by the count of most used?
I think you should change
has_one :articletohas_many :articles.So my version: