Skip to content
This repository has been archived by the owner on Nov 13, 2021. It is now read-only.

Order an array by reputation #58

Open
julio336 opened this issue May 23, 2013 · 1 comment
Open

Order an array by reputation #58

julio336 opened this issue May 23, 2013 · 1 comment

Comments

@julio336
Copy link

I'm trying to order a big array by reputation using the ActiveRecordReputation gem.

Is it possible?

I have a model call Microposts, It has a reputation system called :votes.

Those microposts belongs to other model call Group and a User have many groups.

I need to get all the microposts of the groups that the User is suscribe and order it by reputation.

I get a big array of microposts like this:

@microposts = Micropost.joins(:group => :users).where(:users => {id: current_user.id})
But it stil missing the reputation order.

I hope you can help me!

@archonic
Copy link

archonic commented Apr 3, 2014

@microposts = Micropost.joins(:group => :users).where(:users => {id: current_user.id}).find_with_reputation(:votes, :all, {:order => 'votes DESC'})

Better late than never?

Personally I'd like to know how to do the same, but get an ActiveRecordRelation instead of an array, so I can append search params.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants