Rails can't see my controller
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 re开发者_运维技巧cognized 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.
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
精彩评论