开发者

Why is my form_tag method a post when I am asking for a get?

My form_tag looks like:

<%= form_tag(:controller => "users", :action => "confirm", :method => "get") %>

the html output is:

<form accept-charset="UTF-8" action="/users/confirm?method=get" method="post">

Wh开发者_如何学Pythony is it doing this?


I think it's because when used in this form it assumes all of the options are url options. Try.

<%= form_tag( '/users/confirm', :method => :get ) %>

In this case you have two separate sets of options, url options and tag options.


The first 2 parameters of form_tag are url_for_options and options. Both are hash. So in your code, the whole hash is taken as url_for_options. So, to separate the parameters, you have to do like this:

<%= form_tag({:controller => "users", :action => "confirm"}, {:method => "get"}) %>

or

<%= form_tag({:controller => "users", :action => "confirm"}, :method => "get") %>

Refer link

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜