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

Open
marclipovsky opened this Issue Jun 28, 2012 · 0 comments

Comments

Projects
None yet
1 participant

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment