Ruby on Rails 3 link_to - 为什么我会得到不同的html链接?

时间:2010-09-21 18:40:01

标签: ruby-on-rails

<%= link_to 'Testing', wak_path %>

*This requires a routes: match 'wak', :to => 'home#wak'

他们是不是从rails 3.0中取出了这个或者发生了什么?

<%= link_to 'Testing, :controller=>:home,:actions=>:wak %>

但是在视图中,我得到两个不同的代码,top方法有效,但第二种方法没有相同的行为。为什么是这样?

我刚做了一些测试,这是我在改变params时想出来的。以及我得到的输出。

<%= link_to 'hello', test_path, :remote=>true%>
<a href="/test" data-remote="true">hello</a> 

<%= link_to 'hello', {:controller=>:home,:actions=>:test}, :remote=>true%>
<a href="/home/index?actions=test" data-remote="true">hello</a> 


<%= link_to 'hello', :url=>{:controller=>:home,:actions=>:test}, :remote=>true%>
<a href="/home/index?url[controller]=home&amp;url[actions]=test&amp;remote=true">hello</a>

1 个答案:

答案 0 :(得分:2)

使用:action而不是:actions,这是不正确的