Topic: how to get a value of association of another model in ruby on rails?

If i have two models like 'Question' and 'Answer'. 'Question' has three columns like 'question_id, question_type, question_text ' and 'Answer' has three values 'answer_id, question_id, answer_text'.

I am creating form for the 'Answer' model.


<%= f.text_field :question_id %>.
<%= f.hidden_field :question_id %>.

Here, I am using the 'hidden field' to find the 'question_type'. I tried the map method, but that doesn't work. So Somebody help me to get the 'question_type' value by the selection of that 'question_id.'


Last edited by Sriganesh (2012-10-10 17:24:33)