aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorJames Miller <james@jkmillertech.com>2010-04-06 14:27:19 -0700
committerJames Miller <james@jkmillertech.com>2010-04-06 14:27:19 -0700
commit92eab845a422436aaba4abc9de90f937a91c6a4e (patch)
tree277ad9357f2bb6a06b2143cb8a185d5cf037e4f6 /railties
parent80e7178789496921a7c6b1ea806d7a2e3abe66b4 (diff)
downloadrails-92eab845a422436aaba4abc9de90f937a91c6a4e.tar.gz
rails-92eab845a422436aaba4abc9de90f937a91c6a4e.tar.bz2
rails-92eab845a422436aaba4abc9de90f937a91c6a4e.zip
First run of updating erb syntax for 3.0
Diffstat (limited to 'railties')
-rw-r--r--railties/guides/source/form_helpers.textile18
-rw-r--r--railties/guides/source/getting_started.textile10
2 files changed, 14 insertions, 14 deletions
diff --git a/railties/guides/source/form_helpers.textile b/railties/guides/source/form_helpers.textile
index 441899ba32..050486a5a4 100644
--- a/railties/guides/source/form_helpers.textile
+++ b/railties/guides/source/form_helpers.textile
@@ -21,7 +21,7 @@ h3. Dealing with Basic Forms
The most basic form helper is +form_tag+.
<erb>
-<% form_tag do %>
+<%= form_tag do %>
Form contents
<% end %>
</erb>
@@ -59,7 +59,7 @@ To create this form you will use +form_tag+, +label_tag+, +text_field_tag+, and
A basic search form
<html>
-<% form_tag(search_path, :method => "get") do %>
+<%= form_tag(search_path, :method => "get") do %>
<%= label_tag(:q, "Search for:") %>
<%= text_field_tag(:q) %>
<%= submit_tag("Search") %>
@@ -222,7 +222,7 @@ end
The corresponding view +app/views/articles/new.html.erb+ using +form_for+ looks like this:
<erb>
-<% form_for :article, @article, :url => { :action => "create" }, :html => {:class => "nifty_form"} do |f| %>
+<%= form_for :article, @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 +&lt;form&gt;+ 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:
<erb>
-<% form_for :person, @person, :url => { :action => "create" } do |person_form| %>
+<%= form_for :person, @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 %>
@@ -554,11 +554,11 @@ A common task is uploading some sort of file, whether it's a picture of a person
The following two forms both upload a file.
<erb>
-<% form_tag({:action => :upload}, :multipart => true) do %>
+<%= form_tag({:action => :upload}, :multipart => true) do %>
<%= file_field_tag 'picture' %>
<% end %>
-<% form_for @person, :html => {:multipart => true} do |f| %>
+<%= form_for @person, :html => {:multipart => true} do |f| %>
<%= f.file_field :picture %>
<% end %>
</erb>
@@ -591,7 +591,7 @@ h3. Customizing Form Builders
As mentioned previously the object yielded by +form_for+ and +fields_for+ is an instance of FormBuilder (or a subclass thereof). Form builders encapsulate the notion of displaying form elements for a single object. While you can of course write helpers for your forms in the usual way you can also subclass FormBuilder and add the helpers there. For example
<erb>
-<% form_for @person do |f| %>
+<%= form_for @person do |f| %>
<%= text_field_with_label f, :first_name %>
<% end %>
</erb>
@@ -599,7 +599,7 @@ As mentioned previously the object yielded by +form_for+ and +fields_for+ is an
can be replaced with
<erb>
-<% form_for @person, :builder => LabellingFormBuilder do |f| %>
+<%= form_for @person, :builder => LabellingFormBuilder do |f| %>
<%= f.text_field :first_name %>
<% end %>
</erb>
@@ -694,7 +694,7 @@ The previous sections did not use the Rails form helpers at all. While you can c
You might want to render a form with a set of edit fields for each of a person's addresses. For example:
<erb>
-<% form_for @person do |person_form| %>
+<%= form_for @person do |person_form| %>
<%= person_form.text_field :name %>
<% for address in @person.addresses %>
<% person_form.fields_for address, :index => address do |address_form|%>
diff --git a/railties/guides/source/getting_started.textile b/railties/guides/source/getting_started.textile
index 485a35c3cb..17279146a7 100644
--- a/railties/guides/source/getting_started.textile
+++ b/railties/guides/source/getting_started.textile
@@ -602,7 +602,7 @@ The +&lt;%= render 'form' %&gt;+ line is our first introduction to _partials_ in
If you take a look at +views/posts/_form.html.erb+ file, you will see the following:
<erb>
-<% form_for(@post) do |f| %>
+<%= form_for(@post) do |f| %>
<%= f.error_messages %>
<div class="field">
@@ -906,7 +906,7 @@ So first, we'll wire up the Post show template (+/app/views/posts/show.html.erb+
</p>
<h2>Add a comment:</h2>
-<% form_for([@post, @post.comments.build]) do |f| %>
+<%= form_for([@post, @post.comments.build]) do |f| %>
<%= f.error_messages %>
<div class="field">
@@ -1041,7 +1041,7 @@ Then in the +app/views/posts/show.html.erb+ you can change it to look like the f
:collection => @post.comments %>
<h2>Add a comment:</h2>
-<% form_for([@post, @post.comments.build]) do |f| %>
+<%= form_for([@post, @post.comments.build]) do |f| %>
<%= f.error_messages %>
<div class="field">
@@ -1070,7 +1070,7 @@ h4. Rendering a Partial Form
Lets also move that new comment section out to it's own partial, again, you create a file +app/views/comments/_form.html.erb+ and in it you put:
<erb>
-<% form_for([@post, @post.comments.build]) do |f| %>
+<%= form_for([@post, @post.comments.build]) do |f| %>
<%= f.error_messages %>
<div class="field">
@@ -1278,7 +1278,7 @@ We will modify +views/posts/_form.html.erb+ to render a partial to make a tag:
<erb>
<% @post.tags.build %>
-<% form_for(@post) do |post_form| %>
+<%= form_for(@post) do |post_form| %>
<%= post_form.error_messages %>
<div class="field">