简体   繁体   中英

uninitialized constant ActionController (NameError)

I'm getting this error when trying to deploy.

/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'

I am using Cloud9.

Please help me, I wonder "ActionController::Base" spells miss. But this is correct...

I believe you are starting the server using C9's 'run' command. Instead try running your code with this in the C9 terminal (make sure you are in the correct directory):

rails s -b $IP -p $PORT

A Cloud9 popup should appear that you can click the link to view your code.

I think you forgot to run the rails server

Run the rails server command and then preview running application

~/environment/hello_app (master) $ rails server

运行 Rails 服务器

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM