Cant use with clauses in find_by_sql
Posted
by
PaulMurrayCbr
on Stack Overflow
See other posts from Stack Overflow
or by PaulMurrayCbr
Published on 2012-09-19T07:08:02Z
Indexed on
2012/09/20
3:38 UTC
Read the original article
Hit count: 105
ruby-on-rails
|activerecord
Activerecord seems to be peeking at my sql and getting it wrong. I am finding that this:
sql = "
select etn.*
from edittree_name etn where id = #{id}"
Name.find_by_sql(sql)
works, but this:
sql = "
with pp as ( select * from dual)
select etn.*
from edittree_name etn where id = #{id}"
Name.find_by_sql(sql)
Gives me a "undefined method `each' for 1:Fixnum".
Any clues? Is there a "find_by_raw_sql (and don't try to understand it yourself)" method?
© Stack Overflow or respective owner