Rails:将多个参数传递给form_for url?

nee*_*zer 9 ruby-on-rails

这非常有效:

- form_for @user, :url => { :action => :create, :type => @type } do |f| ...
Run Code Online (Sandbox Code Playgroud)

返回 /users/(id)?type=type

但在另一个视图中,我需要将两个参数传递给URL字符串,这不起作用:

- form_for @user, :url => { :action => :update, :type => @type, :this => @currently_editing } do |f| ...
Run Code Online (Sandbox Code Playgroud)

返回 /users/(id)?this=currently_editing

我也尝试过:

- form_for @user, :url => { :action => :update, :params = params.merge({:this => @currently_editing, :type = @type})} do |f| ...
Run Code Online (Sandbox Code Playgroud)

......没有运气(错误:只允许GET请求).

我想要的是它返回这个: /users/(id)?this=currently_editing&type=type

思考?

sco*_*ttd 25

为什么需要将它们传递给URL字符串?为什么不将它们添加为表单中的隐藏字段?在几乎所有情况下,您都应该使用POST传递变量.