In this case it applies both orders if want to ignore previous scope then use this:
@words = Word.unscoped.order("created_at DESC").page params[:page]
Question
I'm using kaminari
for pagination in rails.
if I set default_scope order("created_at DESC")
in model, it works as expected.
But when I write in controller like this, the DESC
is ignored and pages are ordered by ascendent. (In this case I don't write default_scope
in model.)
def index
@words = Word.order("created_at DESC").page params[:page]
end
What am I doing wrong?
Solution
In this case it applies both orders if want to ignore previous scope then use this:
@words = Word.unscoped.order("created_at DESC").page params[:page]