I got this code, and i get the "Missing method" when i try to use the second more elegant approach. I think the documentation at: http://guides.rubyonrails.org/active_record_querying.html is rather unhelpful or incomplete. Any ideas?
By the way, feel free to help write an even more "oneliner" elegant approach to this :)
def index
@sortby = params[:sort_by]
# THIS WORKS
#if @sortby == nil
# @movies = Movie.all
#else
# @movies = Movie.order(@sortby)
#end
# THIS DOESNT. WHY? I THOUGHT METHOD CHAINING AND LAZYLOAD WOULD WORK.
@movies = Movie.all
@movies = @movies.order(@sortby) unless @sortby == nil
end