[Rails] activerecord variable apart from member
Hi,
I have a table with a field of user_id. In find , i had created a join
on user table to retreive the username as:
@question = Question.find(params[:id], :select=>"questions.*,
users.username as username",:joins=>" inner join users on users.id =
questions.user_id");
I had created an instance variable in Question class with name
"username". But i am not able to access the data. I want to access it as
question.username. can anyone help me out.
Also i am not preffering associations to get the complete user field, as
its not being needed.
Thanks in advance.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home