未初始化的常量ActionController(NameError)

时间:2016-03-10 18:10:34

标签: ruby-on-rails ruby

我在尝试部署时遇到此错误。

/home/ubuntu/workspace/hello_app/app/controllers/application_controller.rb:1:in `<main>': uninitialized constant ActionController (NameError)

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
  # The priority is based upon order of creation: first created -> highest priority.
  # See how all your routes lay out with "rake routes".

  # You can have the root of your site routed with "root"
  root 'application#hello'

我正在使用Cloud9。

请帮助我,我想知道&#34; ActionController :: Base&#34;法术错过了。但这是正确的......

2 个答案:

答案 0 :(得分:1)

我相信你是在使用C9&#39; run&#39;来启动服务器的。命令。而是尝试在C9终端中使用此代码运行代码(确保您位于正确的目录中):

rails s -b $IP -p $PORT

应该会出现一个Cloud9弹出窗口,您可以单击该链接查看您的代码。

答案 1 :(得分:0)

我想你忘了运行rails服务器

运行rails server命令,然后预览正在运行的应用程序

~/environment/hello_app (master) $ rails server

Running the Rails server