Rails ActiveRecord methods in different places [closed]

You can do something like this :

if ..something..
  @posts = Post.where(..something..)
else
  @posts = Post.where(..something..)
end

@posts = @posts.all(:order => ..something..)

It’s better to do this, in Rails 3 :

@posts = @posts.order(..something..)

Leave a Comment