I am new to Rails, and I was curious that some of the experts use it when they need to build a very complex SQL query that contains a lot of conditions. In particular, keeping the code readable and supported.
There are several ways I can think of:
Single line in find () call:
@pitchers = Pitcher.find(:all, "<conditions>")
Use a predefined string and pass it:
@pitchers = Pitcher.find(:all, @conditions)
Use a private member function to return a request
@pitchers = Pitcher.find(:all, conditionfunction)
I seem to be inclined to a conditional agreement on a private member, in addition, because you can pass parameters to configure the request.
Any thoughts on this?
source
share