Currently, I'm doing the conditions in the view. I need to do it in model or controller, but haven't found a way to do it that works.
I have a view rendering 10 users via a partial that sorts them by their friends count (all examples simplified):
Index.html.erb
<%= render @users %>
_partial.html.erb
<% unless current_user == user or current_user.friending?(user) %>
<%= user.name %>
<% end %>
models/user.rb
scope :top, :order => "friends_count DESC"
users_controller.rb/index
@users = User.top.limit(10)
But in my case, it checks the validations in the partial for each user. How can I do it more effectively in the scope or controller and check for all?
Thanks greatly for all answers. Hugely appreciated.