问题
Has any one come across this error?
NoMethodError (undefined method `new' for LinkedIn:Module)
I think it's related to omniauth and linkedin. Here's my Gemfile:
gem 'omniauth'
gem 'linkedin', :git => "git://github.com/redbeard-tech/linkedin.git", :branch => 'jsapi'
I'm using:
- ruby 1.8.7 (2010-01-10 patchlevel 249)
- rails 3.0.5
What might be the reason for it?
回答1:
Check what version of omniauth you are using. We recently ran into this and it was from our dev environment having omniauth 0.3.x and the new environment getting the new 1.0 release. On the omniauth github site it says:
OmniAuth 1.0 has several breaking changes from version 0.x. You can set the dependency to ~> 0.3.2 if you do not wish to make the more difficult upgrade. See the wiki for more information.
I suspect you're being bitten by that.
回答2:
From the error message it looks like you are calling LinkedIn.new(...)
, but looking at the documentation it seems like it should be LinkedIn::Client.new('your_consumer_key', 'your_consumer_secret')
. LinkedIn
is a module, not a class and therefore doesn't have a new
method. However, there seems to be class called Client
defined within this module, which you have to instantiate.
来源:https://stackoverflow.com/questions/8284063/ruby-on-rails-linkedinmodule-error