我已经偶然发现了Hartl教程的第1章清单1.8。无法修改'hello world'应用程序的应用程序控制器
目标是将hello
操作放入应用程序控制器。
这是应该发生:
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception`
def hello
render text: "hello, world!"
end
end
相反,当我把在第一线
class ApplicationController < ActionController::Base
我得到这个:
bash: ActionController::Base: No such file or directory
什么我没有e:
我知道应用程序控制器存在,因为$ ls app/controllers/*_controller.rb
返回应用程序控制器文件。
我在控制器上发现的其他问题涉及到目前为止还没有提到的SecurityMethods等主题。
我也试过只是输入class ApplicationController
,被告知bash: class: command not found
。
问:在采取这一步骤之前,我应该有一个ActionController::Base
吗?
你只是在命令行输入这个? –
@BradWerth是对的,你直接在命令行输入('bash')。运行Rails控制台:'rails console'(rails> = 3)或'script/console'(rails <3)来运行你的命令。 – pierallard
好的。所以我运行了'rails console',命令行变成了这个'2.1.5:001>'。我输入''ApplicationController“类ApplicationController ' –