How to make activerecord use a field generated on the fly by find_by_sql

Posted by Tam on Stack Overflow See other posts from Stack Overflow or by Tam
Published on 2010-03-29T05:43:19Z Indexed on 2010/03/29 6:03 UTC
Read the original article Hit count: 225

I'm using find_by_sql with Activerecord which I generate another field there that doesn't in the original table as a combination of different fields like:

select (field1 + field2) as new_field_name

If I try to access the newly generated field like:

@user.new_field_name

I get nothing! How do you suggest I should approach this problem

© Stack Overflow or respective owner

Related posts about activerecord

Related posts about ruby-on-rails