I am trying to learn Rails 4
framework and followed official doc
I ran these following commands:
rails new fold
It created a new project
rails generate controller home index
It generate a home_controller
and views/home/index.html.erb
Content of home_controller
:
class HomeController < ApplicationController
def index
end
end
For routing I added following code in routes.rb
get 'home/index' => 'home#index'
After running the application I am getting :
uninitialized constant ApplicationController
What I am doing wrong here? Here is the Stacktrace
app/controllers/home_controller.rb:1:in `<top (required)>'
activesupport (4.2.4) lib/active_support/inflector/methods.rb:261:in `const_get'
activesupport (4.2.4) lib/active_support/inflector/methods.rb:261:in `block in constantize'
activesupport (4.2.4) lib/active_support/inflector/methods.rb:259:in `each'
activesupport (4.2.4) lib/active_support/inflector/methods.rb:259:in `inject'
activesupport (4.2.4) lib/active_support/inflector/methods.rb:259:in `constantize'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:72:in `controller_reference'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:62:in `controller'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:41:in `serve'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:821:in `call'
What is the wrong with the code?
Do you have an application.rb file? This file should be sitting inside of app/controllers. All of the other controllers inherit from this controller. The most minimal setup would look like this:
class ApplicationController < ActionController::Base
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With