2010-03-03 125 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