1

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. 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. However, when I try to run rails generate devise User , I get this error: undefined local variable or method config for main:Object (NameError). How do I fix this?

devise.rb file :

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:

*******::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
tshepang
  • 12,111
  • 21
  • 91
  • 136
Slicekick
  • 2,119
  • 5
  • 24
  • 35
  • the correct command is `rails generate devise User` i am not sure if you are getting the error due to that but you can try – abhas Jun 10 '12 at 05:46
  • Sorry, edited my question - I was using the correct command. – Slicekick Jun 10 '12 at 05:47
  • please paste your devise.rb file it may be issue in that file as it is not able to find config there – abhas Jun 10 '12 at 05:51
  • which version of devise are you using? – cdesrosiers Jun 10 '12 at 06:02
  • your config variable is not in proper block in any of the config files which is giving this error. devise.rb looking fine try searching in development.rb it is in block `YourApplicationName::Application.configure do` block. – abhas Jun 10 '12 at 06:02
  • what do I need to search for? – Slicekick Jun 10 '12 at 06:03
  • in development.rb look for config variable if it is properly placed in block i have mentioned above. Or in some other config files if it is properly declared or used. – abhas Jun 10 '12 at 06:05
  • its also look fine sorry I had the same issue and it was in there only so I told you to check. – abhas Jun 10 '12 at 06:08
  • paste the whole error message it must be giving you some filename in error also is it? – abhas Jun 10 '12 at 06:13
  • 1
    does anybody happen to know what was causing this? I seem to be having the same issue – DazBaldwin Mar 09 '13 at 14:52

1 Answers1

1

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. 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
Arel
  • 3,888
  • 6
  • 37
  • 91