How could I call the custom sql function on arel?
What I mean: we can do so:
arel_table[:c].sum.as(‘summarizing’)
How could I do so:
arel_table[:created_at].date_format(‘%Y-%m-%d’).as(‘something’)?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
there are only few functions that are predefined like sum, count, average, minimum etc.
If you want to use something custom I believe you should use Arel::Nodes::NamedFunction and database specific functions. For example for PostgreSQL it could be sth like this:
I hope this will help you somehow, cheers