Rails 3:简单的问题渲染:通过link_to文本(将我的头靠在墙上)

时间:2011-05-07 00:27:12

标签: ruby-on-rails ruby-on-rails-3

我正在从2.3.x切换到3.0.7并且我坚持做最简单的事情。

我只是想创建一个指向remote的链接,但它似乎无法正常工作。

来自index.html.erb

<%= link_to "test", test_path, :remote => true, :update => "test_div" %>
<div id="test_div"></div>

来自home_controller.rb

def index  
end

def test
    render :text => 'test'
end

来自routes.rb

match '/' => 'home#index'
match '/test', :to => 'home#test'  

应该是简单的东西。我单击链接“test”并在服务器控制台中:

Rendered home/index.html.erb within layouts/application (15.6ms)
Completed 200 OK in 31ms (Views: 31.2ms | ActiveRecord: 0.0ms)

Started GET "/test" for 127.0.0.1 at Fri May 06 20:15:03 -0400 2011
  Processing by HomeController#test as JS
Rendered text template (0.0ms)
Completed 200 OK in 16ms (Views: 15.6ms | ActiveRecord: 0.0ms)

在萤火虫中它说:

GET http://localhost:3001/test 304 Not Modified 40ms    

Response

test

我的test_div中没有​​显示任何内容。我不明白,我做错了什么?

1 个答案:

答案 0 :(得分:1)

:update已从Rails 3中删除。您可以查看Rails 2 to Rails 3 : using link_to instead of link_to_remote (including remote and update)以获取一些详细信息,并了解其他获取所需内容的方法。