Re: HTML shortcuts

Frederick Cheung
Mon, 28 Dec 2009 16:38:14 -0000

On Dec 28, 4:31 pm, Marnen Laibow-Koser
<li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:
> Yes.  It calculates the URL for the form from the controller and action,
> which is a big help since Rails doesn''t use direct URLs much.  In
> addition, if you use form_for, it also creates a FormBuilder object so
> you can use Rails'' helpers for form elements, which automatically
pick
> up values from the object. .
>
And with form_for rails works out for you whether the form''s action
should be the url for saving or updating the form etc.

It''s true that

<%= start_form_tag ({:action => "at"}, {:method =>
"post"}) %>
<%= end_form_tag %>

is not very different from

<form action = "/look/at" method = "post"


but

<% form_for @person do |f| %>
  <%= f.label :name %>: <%= f.text_field :name%>
<% end %>

is less cumbersome than the alternative.

Fred

--

You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.