Form_tag weirdness


#1

The docs state:
form_tag(url_for_options = {}, options = {},
*parameters_for_url)

So I thought this would work:
<%= form_tag {:controller=>‘member’,:action =>
‘validate_login’} %>

But that gives this error:
compile error
./app/views/member/login.rhtml:2: syntax error
_erbout.concat(( form_tag
{:controller=>‘member’,:action => ‘validate_login’}
).to_s); _erbout.concat “\r\n”
^
./app/views/member/login.rhtml:2: syntax error
_erbout.concat(( form_tag
{:controller=>‘member’,:action => ‘validate_login’}
).to_s); _erbout.concat “\r\n”

However, both of these work:
<%= form_tag ({:controller=>‘member’,:action =>
‘validate_login’}) %>
<%= form_tag :controller=>‘member’,:action =>
‘validate_login’ %>

I’m confused - the docs lead me to think that the
url_for_options need to be in a hash, lest they get
confused with the other params.

csn


Start your day with Yahoo! - Make it your home page!


#2

CSN wrote:

./app/views/member/login.rhtml:2: syntax error
<%= form_tag ({:controller=>‘member’,:action =>
‘validate_login’}) %>
<%= form_tag :controller=>‘member’,:action =>
‘validate_login’ %>

The way Ruby parses this case where all parameters
are optional is to treat the bracketed section as
a block rather than a hash, so you need to use the
other forms you mention.