Me_ok_small Ilya Sabanin 1 post

Excerpt from Jay Field’s receipt “Simplifying Controllers With a Presenter”:

Lastly, using three different models doesn’t allow us to take advantage of Rails form_for method.

It’s not true. It’s possible to use form_for with multiply models using fields_for block:


<% form_for :user do |form| -%>
  <%= form.text_field :first_name %>
  <%= form.text_field :email %>

  <% fields_for :credit_card do |card_form| -%>
    <%= card_form.text_field :number %>
  <% end -%>
  <%= submit_tag %>
<% end -%>

More information in Rails 2.0.1 API.

 
Mike-120_small Mike Clark Administrator 26 posts

Thanks. You’re correct that it’s misleading. I’ll clarify it, and the book will also have a full recipe on fields_for in the next beta version.

In future, I’d appreciate it if you’d add comments such as these (errors, omissions, etc.) to the errata page so I can track them better.

2 posts, 2 voices