hillam/ctt-server

order sites on the profile by time desc

Closed this issue · 1 comments

I plugged this in.. after some testing in irb, it seemed like it would do the trick, but I've had no such luck.

user = User.find(params[:user_id])
query = user.sites.visible(current_user)
@sites = query.sort{|a,b| b.time <=> a.time}.to_a

I can't exactly do query.order_by('time DESC'), because time is a scope, not a column.

The sites_table partial gets rendered by the users#show view, not the sites#index controller (shown above).

I added the .sort shown above to the self.visible definition in the Site model. This returns a sorted list of sites whenever .visible(user) is called (like on the profile).

Implemented on ca899d4