meta_search icon indicating copy to clipboard operation
meta_search copied to clipboard

Sort Virtual Attribute (or for this purpose associated records count)

Open marclipovsky opened this issue 12 years ago • 0 comments

I'd like to be able to sort the associated records count. For example:

# form.rb
class Form
    has_many :references

    def reference_count
        self.references.count
    end
end

# reference.rb
class Reference
    belongs_to :form
end

#my view
= sort_link @search, :reference_count, 'References'

Is this possible? Or being able to sort the count directly without the virtual attribute.

Thanks!

marclipovsky avatar Jun 28 '12 00:06 marclipovsky