Ruby on Rails 3.0为什么这两个输出两个不同的东西?

时间:2010-09-17 17:12:54

标签: 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>

3 个答案:

答案 0 :(得分:1)

在第二种方法中,您忘记关闭测试的引用。它应该是

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

在rails 3中,第二种方法工作正常,您也可以通过在命令行 rake routes 中写入来检查路由,并检查每个路由助手方法是否与控制器匹配 - 操作。

答案 1 :(得分:0)

测试后缺少报价?

答案 2 :(得分:0)

:行动而不是:行动

相关问题