1
votes

I'm trying to use Linkedin's api for authentication in my rails app. I'm pretty new to rails so I followed this guide http://sourcey.com/rails-4-omniauth-using-devise-with-twitter-facebook-and-linkedin/

I've tried to run rake db:migrate but get this error. The full trace is below. I've also added the environment.rb file as I think that's where the problem is but I'm not sure. Also, if anyone has a better guide for using linkedin apis with rails please share! Thanks for the help!

rake aborted! NameError: undefined local variable or method config' for main:Object /Users/alexanderkehaya/Desktop/codea/codea_app/config/environment.rb:4:in' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in require' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:inblock in require' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in load_dependency' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:inrequire' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/railties-4.1.5/lib/rails/application.rb:276:in require_environment!' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/railties-4.1.5/lib/rails/application.rb:379:inblock in run_tasks_blocks' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:240:in call' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:240:inblock in execute' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:235:in each' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:235:inexecute' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:179:in block in invoke_with_call_chain' /Users/alexanderkehaya/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:inmon_synchronize' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:172:in invoke_with_call_chain' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:201:inblock in invoke_prerequisites' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:199:in each' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:199:ininvoke_prerequisites' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:178:in block in invoke_with_call_chain' /Users/alexanderkehaya/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:inmon_synchronize' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:172:in invoke_with_call_chain' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:165:ininvoke' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:150:in invoke_task' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:106:inblock (2 levels) in top_level' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:106:in each' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:106:inblock in top_level' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:115:in run_with_threads' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:100:intop_level' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:78:in block in run' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:176:instandard_exception_handling' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:75:in run' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/bin/rake:33:in' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/bin/rake:23:in load' /Users/alexanderkehaya/.rvm/gems/ruby-2.1.2/bin/rake:23:in' Tasks: TOP => db:migrate => environment

environemnt.rb file

require File.expand_path('../application', __FILE__)

config.app_domain = 'somedoamin.com'

config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { host: config.app_domain }
config.action_mailer.smtp_settings = {
  address: 'smtp.gmail.com', 
  port: '587',
  enable_starttls_auto: true,
  user_name: 'someuser',
  password: 'somepass',
  authentication: :plain,
  domain: 'somedomain.com'
 }

Rails.application.initialize!
1

1 Answers

0
votes

Your environment.rb indeed is the problem. All of the config code in it:

config.app_domain = 'somedoamin.com'

config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { host: config.app_domain }
config.action_mailer.smtp_settings = {
  address: 'smtp.gmail.com', 
  port: '587',
  enable_starttls_auto: true,
  user_name: 'someuser',
  password: 'somepass',
  authentication: :plain,
  domain: 'somedomain.com'
 }

Is in the wrong place. It should be in the application.rb or config/environments/development.rb if its development specific.