From bda6de2722a859049fa72c9a5d39880bdb74252f Mon Sep 17 00:00:00 2001 From: oamblet Date: Wed, 15 Sep 2010 10:11:07 +0200 Subject: Updated old fashion form_for samples. when 'form_for :resource, @resource ...' is found, remove the first argument (there is no need to use the :as option when the name is the same). --- railties/guides/source/action_view_overview.textile | 2 +- railties/guides/source/form_helpers.textile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/action_view_overview.textile b/railties/guides/source/action_view_overview.textile index 459d70f111..843dfe530d 100644 --- a/railties/guides/source/action_view_overview.textile +++ b/railties/guides/source/action_view_overview.textile @@ -654,7 +654,7 @@ The core method of this helper, form_for, gives you the ability to create a form # Note: a @person variable will have been created in the controller (e.g. @person = Person.new) -<%= form_for :person, @person, :url => { :action => "create" } do |f| %> +<%= form_for @person, :url => { :action => "create" } do |f| %> <%= f.text_field :first_name %> <%= f.text_field :last_name %> <%= submit_tag 'Create' %> diff --git a/railties/guides/source/form_helpers.textile b/railties/guides/source/form_helpers.textile index 146b75da3f..26cbdfc44f 100644 --- a/railties/guides/source/form_helpers.textile +++ b/railties/guides/source/form_helpers.textile @@ -222,7 +222,7 @@ end The corresponding view +app/views/articles/new.html.erb+ using +form_for+ looks like this: -<%= form_for :article, @article, :url => { :action => "create" }, :html => {:class => "nifty_form"} do |f| %> +<%= form_for @article, :url => { :action => "create" }, :html => {:class => "nifty_form"} do |f| %> <%= f.text_field :title %> <%= f.text_area :body, :size => "60x12" %> <%= submit_tag "Create" %> @@ -253,7 +253,7 @@ The helper methods called on the form builder are identical to the model object You can create a similar binding without actually creating +<form>+ tags with the +fields_for+ helper. This is useful for editing additional model objects with the same form. For example if you had a Person model with an associated ContactDetail model you could create a form for creating both like so: -<%= form_for :person, @person, :url => { :action => "create" } do |person_form| %> +<%= form_for @person, :url => { :action => "create" } do |person_form| %> <%= person_form.text_field :name %> <%= fields_for @person.contact_detail do |contact_details_form| %> <%= contact_details_form.text_field :phone_number %> -- cgit v1.2.3