Forum: Ruby on Rails Problem with helper form_tag syntax

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
andi (Guest)
on 2005-11-25 13:03
(Received via mailing list)
Hi,

the Rails book says i can use something like this in my view

   <%= form_tag :action => :new, {:class => 'more'}  %>

This gives an syntax error, whereas only this (ugly looking) works:

   <%= form_tag( {:action => :new} , {:class => 'more'} ) %>

some ruby syntax stuff i get wrong here?


Best
Andi
brad (Guest)
on 2005-11-25 17:22
(Received via mailing list)
AFAIK, Ruby collects any hash parameters at the *end* of the argument
list into a hash. So,

<%= form_tag {:action => :new}, :class => 'more' %>

may work. On the other hand, IIRC, it is considered deprecated to
omit the parentheses on functions in views now. You would probably
get a warning on the above. So the 'minimalist' correct ERb code
would probably look like this:

<%= form_tag( {action => :new}, :class => 'more' ) %>

--
Brad E.
866-EDIGERS
andi (Guest)
on 2005-11-25 21:21
(Received via mailing list)
Hey Brad,

thanks for clarifying this.

-andi
This topic is locked and can not be replied to.