2

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|

2 Answers 2

13

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
0
-3

You'll get the same error if you run this 'program':

resource_class.omniauth_providers.each do |provider|
end

You have to define resource_class somewhere. Are you a spammer for Railscasts? It doesn't really help to provide a link for something that costs money to see.

3
  • Ah forgive me, I have edited out some of the content I quoted from railscasts, and No I am not a spammer, I am a subscribed member and love Ryan's Videos. What could I define "resource_class" as? Jul 5, 2013 at 6:18
  • A 'resource' in rails is represented by a db table. And a 'resource_class' is probably the model associated with that table.
    – 7stud
    Jul 5, 2013 at 10:46
  • Take a look at the answer I just posted, you need to define resource_class in your application_helper.rb Aug 7, 2013 at 0:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.