Im new to rails and I want to make a select query based on diffrent GET params (filtering and sorting). Can I some how add conditions to find in the code?
For example:
if params[:ratings]
Movie.where(:rating => params[:ratings].keys)
end
and then add ordering and other where conditions. How can I achive this? Maybe there is a better way to dybamicly modify select query (without making SQL string).
Thanks.
The
where,order, … methods return ActiveRecord::Relation objects so you can keep calling more query methods: