'extra' method undefined #558

benjamintanweihao opened this Issue Dec 18, 2011 · 7 comments


None yet

5 participants


Hi all! This is driving me nuts. I've set up Devise 1.5 + Omniauth 1.0. Funny thing is, development mode works fine. But when testing with cucumber, I get this error:

When I follow "Sign in with Facebook" # features/step_definitions/web_steps.rb:57
undefined method
extra' for #Hash:0x007fc59c482bc8 (NoMethodError)
./app/models/user.rb:15:in find_for_facebook_oauth'
(eval):2:in click_link'
/^(?:|I )follow "([^"]*)"$/'
features/facebook.feature:11:in When I follow "Sign in with Facebook"'

I have OmniAuth.config.test_mode = true in test.rb. Any suggestions? Thanks!


FWIW, here's the way I'm getting it to pass the Cucumber tests for now, which is pretty lame. I keep getting trouble at the data.extra.raw_info part:

    def self.find_for_facebook_oauth(access_token, signed_in_resource=nil)

        case Rails.env
        when "test"
            data = access_token['extra']['user_hash']
            if user = User.find_by_email(data["email"])
                User.create!(:email => data["email"], :password => Devise.friendly_token[0,20])
            data = access_token.extra.raw_info
            if user = User.where(:email => data.email).first
                User.create!(:email => data.email, :password => Devise.friendly_token[0,20]) 

Here's my Gemfile:

source 'http://rubygems.org'

gem 'rails', '3.1.1'

gem 'haml'
gem 'jquery-rails'
gem "devise", :git => "https://github.com/plataformatec/devise.git"
gem 'omniauth', :git => 'git://github.com/piotrj/omniauth.git'
gem 'omniauth-facebook'
gem 'pg'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'coffee-rails', '~> 3.1.1'
  gem 'sass-rails',   '~> 3.1.5'
  gem 'uglifier', '>= 1.0.3'

group :development do
  gem 'sqlite3'
    gem 'haml-rails', '>= 0.3.4'

group :development, :test do
    gem 'rspec-rails'
    gem 'ZenTest'
  gem 'autotest-fsevent'    
  gem 'autotest-growl'
  gem 'autotest-rails'

group :test do
    gem 'cucumber-rails', '1.0.6'
  gem 'capybara'
  gem 'database_cleaner'
  gem 'email_spec'
  gem 'factory_girl'
  gem 'minitest'
  gem 'spork', '> 0.9.0.rc'
  gem 'turn', '~> 0.8.3', :require => false


This error should be fixed while Pull Request #556 will get merged.


Thanks! I think I tried your fix, is it the one stated in the Gemfile I have above? Seems like not many people are having this strange issue. Anyhow, thanks for the patch!


Probably people don't use the Mash functionality -> using data.extra instead of data["extra"]. That's why they don't stumble upon this issue.

If you want to use my fix for now then except for using my fork you need to specify that you want to use branch mash_in_test_mode - use smth like that:

gem 'omniauth', :git => 'git://github.com/piotrj/omniauth.git', :branch => "mash_in_test_mode"

Hi piotrj, I have tried your fix but I'm still running into the same issues. :(.


I have submited my patch to solve this issue, you can find it here: #564
Also encountered this problem and my patch solves this issue.

@mbleigh mbleigh closed this Jan 17, 2012

I still have the same issue - ive been pulling out my hair with this. Did anyone manage to get it working?

I tried:

gem 'omniauth', :git => 'git://github.com/piotrj/omniauth.git', :branch => "mash_in_test_mode"

gem 'omniauth', :git => 'https://github.com/dombesz/omniauth.git'

neither worked ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment