I have the following database:
class User < ActiveRecord::Base
has_and_belongs_to_many :apps
class App < ActiveRecord::Base
has_and_belongs_to_many :users
In the view for a User (users/show.html.haml
) I want to list all the Apps sorted by the ones the current user has.
%table
%thead
%tr
%th Name
%th Available
- for app in App.order("??????")
%tr
%td= link_to app.name, app_path(app)
%td
- if @user.apps.include?(app)
%i.icon-ok
- else
%i.icon-remove
My question is what do I put in the order function to do the sort.