svfreerider
svfreerider

Reputation: 11

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...

Upvotes: 1

Views: 4537

Answers (2)

ishan verma
ishan verma

Reputation: 1

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

Running the Rails server

Upvotes: 0

jdgray
jdgray

Reputation: 1983

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.

Upvotes: 1

Related Questions