轨道设计生成错误



我对rails相当陌生,我正在尝试设置设计和全能身份验证,以允许用户使用Facebook API登录我的网站。我正在使用本教程 http://www.ruby-on-rails-outsourcing.com/articles/2012/01/20/adding-facebook-auth-to-rails-3-1-app/来执行此操作。但是,当我尝试运行rails generate devise User时,出现此错误:undefined local variable or method config for main:Object (NameError)。我该如何解决这个问题?

设计.rb 文件 :

Devise.setup do |config|
  config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com" 
  require 'devise/orm/active_record'
  config.case_insensitive_keys = [ :email ]
  config.strip_whitespace_keys = [ :email ]
  config.skip_session_storage = [:http_auth]
  config.stretches = Rails.env.test? ? 1 : 10
  config.reconfirmable = true
  config.reset_password_within = 6.hours
  config.sign_out_via = :delete

发展.rb:

*******::Application.configure do
  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
  config.cache_classes = false
  config.whiny_nils = true
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false
  config.action_mailer.raise_delivery_errors = false
  config.active_support.deprecation = :log
  config.action_dispatch.best_standards_support = :builtin
  config.active_record.mass_assignment_sanitizer = :strict
  config.active_record.auto_explain_threshold_in_seconds = 0.5
  config.assets.compress = false
  config.assets.debug = true
end

我遇到了完全相同的问题。 评论中的阿巴斯帮助我走上了正确的轨道!

我把config.assets.initialize_on_precompile = false放在config/Application.rb文件夹中Module ApplicationName块之外。我将该配置行放在模块块中,一切开始运行良好!

module VitogoWeb2
  class Application < Rails::Application
    # A devise setting to prevent Heroku from accessing the DB or load models when precompiling the assets.
    config.assets.initialize_on_precompile = false
  end
end

相关内容

  • 没有找到相关文章

最新更新