problem using default_scope on a model table
- by DannyRe
Hey. In my controller/index action I use the following query:
@course_enrollments = current_user.course_enrollments
This is what my table looks like. It is referencing a course table. The course table has a colum 'title'.
create_table "course_enrollments", :force => true do |t|
t.integer "user_id", :null => false
t.integer "course_id", :null => false
t.datetime "created_at"
t.datetime "updated_at"
end
I want to be able to order my course_enrollments by course in my index view. Furthermore Id like to do a default_scope in my model, like this:
default_scope :order => 'title asc'
any suggestions? Thx for your time