简体   繁体   English

Rails Devise生成错误

[英]Rails Devise generate error

I'm fairly new to rails and I'm trying to set up devise and omniauth to allow users to login to my website with the Facebook API. 我是Rails的新手,我正在尝试设置devise和omniauth以允许用户使用Facebook API登录到我的网站。 I'm using this tutorial http://www.ruby-on-rails-outsourcing.com/articles/2012/01/20/adding-facebook-auth-to-rails-3-1-app/ to do this. 我正在使用本教程http://www.ruby-on-rails-outsourcing.com/articles/2012/01/20/adding-facebook-auth-to-rails-3-1-app/来执行此操作。 However, when I try to run rails generate devise User , I get this error: undefined local variable or method config for main:Object (NameError) . 但是,当我尝试运行rails generate devise User ,出现以下错误: undefined local variable or method config for main:Object (NameError) How do I fix this? 我该如何解决?

devise.rb file : devise.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

development.rb: development.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

I had the exact same problem. 我有同样的问题。 abhas in the comments helped me get on the right track! 评论中的内容帮助我走上了正轨!

I had put config.assets.initialize_on_precompile = false in outside the Module ApplicationName block in the config/Application.rb folder. 我将config.assets.initialize_on_precompile = false放在config/Application.rb文件夹中的Module ApplicationName块之外。 I put that config line in the Module block, and everything started working great! 我将配置行放在模块块中,一切开始正常运行!

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM