Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: undefined local variable or method `resource_class' when installing omniauth-twitter

I am trying to do a sign in with facebook/twitter, and following this railscast

I have added the following to my config/initializers/devise.rb (where I did put in my consumer key and consumer secret as provided by Twitter).

config.omniauth :twitter, ENV["TWITTER_CONSUMER_KEY"], ENV["TWITTER_CONSUMER_SECRET"]

After adding ":omniauthable" to my user model, The following produces this error "undefined local variable or method `resource_class' for #<#:0x007febf67af938>"

- if devise_mapping.omniauthable?
  - resource_class.omniauth_providers.each do |provider|
like image 550
Jeremy Lynch Avatar asked Apr 15 '26 08:04

Jeremy Lynch


1 Answers

I solved this by removing the "ENV[]" brackets:

config.omniauth :twitter, 'TWITTER_CONSUMER_KEY', 'TWITTER_CONSUMER_SECRET'

and defining resource_class in my application_helper.rb

def resource_class
  devise_mapping.to
end
like image 165
Jeremy Lynch Avatar answered Apr 17 '26 22:04

Jeremy Lynch