2010-03-03 139 views
1
class MyTestController < ApplicationController 
    def index 
     render_text "hello world" 
    end 
end 

这是当我去http://127.0.0.1:3000/My_Test/什么我越来越:导轨:文本不渲染

NoMethodError在我的TestController#指数

未定义的方法`render_text”为# RAILS_ROOT:C :/ rails/rails_apps/cookbook

Application Trace |框架跟踪|全面跟踪 应用程序/控制器/ my_test_controller.rb:5:'指数” 请求

参数: 无

显示会话转储

响应头:

{ “曲奇”= > [],“Cache-Control”=>“no-cache”}

请记住我正在关注本教程:

http://oreilly.com/pub/a/ruby/archive/rails.html?page=2

回答

4

该教程是非常古老和过时的。 render_text方法不再存在。尝试改为:

def index 
    render :text => "hello world" 
end 
+0

谢谢你phil!你可以通过一些最新的教程吗? – 2010-03-03 23:07:20

+1

@every_answer您可能想了解一下http://guides.rubyonrails.org/getting_started.html上的“入门指南”指南 – 2010-03-03 23:10:38