1

Given:

Two controllers under /app/controllers named:

  • customers_controller.rb (CustomersController)
  • home_controller.rb (HomeController)

Problem:

When I run rails command (i.e. rails c) this is what I get:

ruby-1.9.2-p290 :001 > CustomersController
 => CustomersController 
ruby-1.9.2-p290 :002 > HomeController
NameError: uninitialized constant HomeController
    from /home/aaron/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.8.7/lib/rake.rb:2503:in `const_missing'
    from (irb):2
    from /home/aaron/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.9/lib/rails/commands/console.rb:44:in `start'
    from /home/aaron/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.9/lib/rails/commands/console.rb:8:in `start'
    from /home/aaron/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.9/lib/rails/commands.rb:23:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

So whats the deal? Why isn't HomeController being recognized by my application?

Edit:

My home_controller.rb file:

class HomeController < ApplicationController
  def index
  end

  def sign_up
  end

  def faq
  end

  def terms
  end

  def privacy
  end

  def feedback
  end

end

Theres not much in it.

aarona
  • 35,986
  • 41
  • 138
  • 186

1 Answers1

1

works for me with Rails 3.0.7 ... which version of Rails are you using?

There was a problem with old versions of Rake in the newer Rails versions, and I noticed that you're using a really old version of Rake..

Try to put this in your Gemfile:

gem 'rake' , '>= 0.9.1'

then do a "bundle update"

and try to do "rails c" again..

does it work for you afterwards?

See also:

Confused with rake error in Rails 3

Community
  • 1
  • 1
Tilo
  • 33,354
  • 5
  • 79
  • 106
  • I'll give this a shot. I think I was using this version for a particular reason that I can remember off the top of my head. – aarona Oct 03 '11 at 18:53