In one of my Rails models I have this:
class Project < ActiveRecord::Base
belongs_to :user
default_scope order("number ASC")
end
Now the problem is that I want each user
to be able to set his or her default_scope
individually. For example, a user A might want default_scope order("date ASC")
, another one might want default_scope order("number DESC")
.
In my User
table I even have columns to store these values: order_column
and order_direction
.
But how can I make the default_scope
in the model dynamic?
Thanks for any help.