Let's say I wanna do
SomeModel.where(blahblah)
and if certain param has been set, then I also want to order the selection
SomeModel.where(blahblah).order(blahblah)
I don't want to have to do
if something
SomeModel.where(blahblah)
else
SomeModel.where(blahblah).order(blahblah)
end
because it's repetitive.
Is there some way that allows me to construct a SQL statement with conditionals, and then execute it later? Something similar to constructing a SQL string through concatenation and then executing the string?