Hello,
I am trying to get specific fields returned from my query but I am not getting some of them.
For example when I use
User.joins(:books).select("users.email, users.fname, books.name").find(7)
The generated SQL Query from above code is
SELECT users.email, users.fname, books.name FROM users INNER JOIN book_users ON users.id = book_users.user_id INNER JOIN books ON books.id = book_users.book_id WHERE users.id = 7 LIMIT 1
Output received is -
#<User email: "email1@email.com", fname: "Arlene">
Rails doesn't return the books.name even though the generated sql query has that an if I run the sql directly I get the three columns.
I am on Rails 3.0.5 and Ruby 1.9.2p180. Is there any configuration setting to enable this or am I missing something here?
Thanks, -S