Problem with helper form_tag syntax


#1

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


#2

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


#3

Hey Brad,

thanks for clarifying this.

-andi