It depends on your application and what you want to execute, but you can define default_scope
in the Question
model as follows:
class Question < ActiveRecord::Base default_scope order('id ASC') end
Or you can define default_scope
in the Book
model:
class Book < ActiveRecord::Base default_scope joins(:questions).order('questions.id ASC') end
If you want to get a load of questions
, use includes
instead of join
.
source share