I am performing this query on my function:
ActiveRecord::Base.connection.execute("SELECT * FROM organic_reports('#{@date}');")
The function is returning the following attributes:
name(string), project_id(int), report_id(int), created_at(date), stats(int)
How can I use ActiveRecord to query those results, like in a normal Rails model? Methods like (where, find etc.)
You can always use from to define the source of the query, and then you can use the ActiveRecord query interface as you normally would.
Model.from("organic_reports('#{@date}')").where('...').group('...')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With