User.find_by_sql("...my statement here...").explain
results in an error undefined method explain for array
... which makes perfect sense to me...
I'm not using rails. I'm using sinatra
although that should not matter since the commands come from the activerecord
gem which I am using...
Any suggestions?
Error is pretty self-explanatory.
You can only run explain
on ActiveRecord::Relation
objects. But find_by_sql
gives you an Array
instead, on which explain
cannot be called.
You have two ways to work around this:
ActiveRecord
methods (which return Relation
)explain
inside your find_by_sql
string.Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments