我正在创建一个Rails 4.2应用程序,在网页上打印“Hello World”。但是在运行页面时,我遇到了以下错误:
未知操作
无法找到ApplicationController的“hello”操作
这些是我更新的文件:
application_controller.rb
未知操作
无法找到ApplicationController的“hello”操作
这些是我更新的文件:
application_controller.rb
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
routes.rb
Rails.application.routes.draw do
# You can have the root of your site routed with "root"
root 'application#hello'
end