Forum: Ruby on Rails form_tag weirdness

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
81194a50c0f9bd95d7832a77fdf371bd?d=identicon&s=25 cool_screen_name90001 (Guest)
on 2005-11-12 12:50
(Received via mailing list)
The docs state:
  form_tag(url_for_options = {}, options = {},

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.


Start your day with Yahoo! - Make it your home page!
C64e63b70be7dfed8b0742540b8b27e5?d=identicon&s=25 mrj (Guest)
on 2005-11-13 05:37
(Received via mailing list)
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.
This topic is locked and can not be replied to.