Rails - Accessing Model Attributes in Forms

Posted by stringo0 on Stack Overflow See other posts from Stack Overflow or by stringo0
Published on 2010-06-13T23:37:13Z Indexed on 2010/06/13 23:42 UTC
Read the original article Hit count: 179

Filed under:
|

Hi,

How do I access a model's parent's attribute in a form? For example, for the following form for answer, I want to access answer.question.text and use that for the question - how do I do this?

Thanks!

<% form_for :answers do |ans| %>
    <%= ans.label :question, "Question" %>
    <%= ans.text_field :value %>

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about forms