0

我是Ruby的新手。我按照本教程安装:http://udooz.net/blog/2011/02/facebook-app-using-rails-koala/

现在,当我这样做时: rails generate controller

rails 生成控制器主页索引

我收到此错误:

/home/hiccup-pro/Documents/qstack/config/environment.rb:8:in `<top (required)>': undefined local variable or method `config' for main:Object (NameError)
from /home/hiccup-pro/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.3/lib/rails/application.rb:103:in `require'
from /home/hiccup-pro/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.3/lib/rails/application.rb:103:in `require_environment!'
from /home/hiccup-pro/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.3/lib/rails/commands.rb:25:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

我修好了它。至少那个错误,但现在我有一个不同的错误,那就是:未初始化的常量 LoginController。我搜索了一下,发现我不应该在 environment.rb 中提及 config.*。无论如何,这是我的环境.rb

# Load the rails application
require File.expand_path('../application', __FILE__)

# Initialize the rails application
Qack::Application.initialize!
config.action_controller.allow_forgery_protection = false

那么,为什么我会收到此uninitialized constant LoginController错误?

4

1 回答 1

1

没有看到你的 environment.rb 很难说,但我最好的拍摄是你把代码

config.action_controller.allow_forgery_protection = false
config.gem "koala"

街区外

Rails::Initializer.run do |config|
  ....
end

那是在 environment.rb 里面。如果没有这样的块添加它是这样的:

Rails::Initializer.run do |config|
  config.action_controller.allow_forgery_protection = false
  config.gem "koala"
end
于 2012-04-30T13:25:32.513 回答