我错过了什么吗?这里我使用Rails 4.2.5和Ruby 2.2.3。
...
#routes.rb
get '/users/:user_id/account/:id' => 'foo#bar', as: 'foo_bar'
...
控制器:
...
#foo_controller.rb
def bar
flash[:warning] = "You have found Bar!."
#return redirect_to x <--- still nothing!
end
...
使用Zurb Foundation 6:
<%= link_to 'Get', foo_bar_path, class: "input-group-button button", method: :get %>
按下按钮后,我在控制台中找回了这个:
开始GET&#34; / users / 1 / account / 2&#34; for :: 1 at 2016-02-11 17:11:04 +0000 由FooController处理#显示为HTML 参数:{&#34; authenticity_token&#34; =&gt;&#34; IT5zcHymgnHqiN1y7SMmMVkL + JlSisKels62qMXy3Y3cD + XXDlGsey / TistN3JaE2a8vZwx / xycUQrQId0Rpsw ==&#34;,&#34; user_id&#34; =&gt;&#34; 1& #34;,&#34; id&#34; =&gt;&#34; 2&#34;}
如何通过link_to正确调用方法?
编辑:
呈现按钮的html:
<a class="input-group-button button" data-method="get" href="/users/1/account/2">Submit</a>