我不明白这里发生了什么.我想button_to在我的(haml)视图中添加一个.如果我这样做:
=button_to( "New", {:action => "new"}, {} )
Run Code Online (Sandbox Code Playgroud)
生成的页面有:
<form action="/cached_input_files/new" class="button_to" method="post">
<div>
<input type="submit" value="New" />
<input name="authenticity_token" type="hidden" value="..blah.." />
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
这没关系,但我需要解决不同的控制器问题.但是,如果我尝试指定控制器:
=button_to( "New", {:action => "new", :controller => "editor"}, {} )
Run Code Online (Sandbox Code Playgroud)
我明白了:
<form action="/assets?action=new&controller=editor" class="button_to" method="post">
<div>
<input type="submit" value="New" />
...
Run Code Online (Sandbox Code Playgroud)
我希望它action是"/editor/new",并且我不知道它为什么不是,也不知道如何正确指定我想要路由到的控制器.
我正在使用Rails 3.2.1.
您不希望将选项包含在自己的哈希中,我认为这会使解释器感到困惑.
=button_to( "New", :action => "new", :controller => "editor")
Run Code Online (Sandbox Code Playgroud)
应该做你想做的事.
| 归档时间: |
|
| 查看次数: |
13836 次 |
| 最近记录: |