我正在从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中没有显示任何内容。我不明白,我做错了什么?
答案 0 :(得分:1)
:update
已从Rails 3中删除。您可以查看Rails 2 to Rails 3 : using link_to instead of link_to_remote (including remote and update)以获取一些详细信息,并了解其他获取所需内容的方法。