Ruby on Rails, LinkedIn:Module error - ruby-on-rails

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?

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.

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.

Related

What's the replacement for acts_as_commentable in Rails 6, Ruby 3.0.2?

I upgraded our app to Rails 6.1.4.4 and Ruby 3.0.2. I have this old gem
gem 'acts_as_commentable'
Locked at version 4.0.2. The gem does not appear to be supported anymore, which is a shame because when I start up my app or console, I now get this error
$ rails c
Your Gemfile lists the gem rspec-rails (>= 0) more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once.
While it's not a problem now, it could cause errors if you change the version of one of them later.
/Users/myuser/.rvm/gems/ruby-3.0.2/gems/hash_dot-2.5.0/lib/hash.rb:19:in `method_missing': undefined method `arity' for {:as=>:commentable, :dependent=>:destroy}:Hash (NoMethodError)
from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/activerecord-6.1.4.4/lib/active_record/associations/builder/association.rb:53:in `build_scope'
from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/activerecord-6.1.4.4/lib/active_record/associations/builder/association.rb:47:in `create_reflection'
from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/activerecord-6.1.4.4/lib/active_record/associations/builder/association.rb:32:in `build'
from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/activerecord-6.1.4.4/lib/active_record/associations.rb:1458:in `has_many'
from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/acts_as_commentable-4.0.2/lib/commentable_methods.rb:58:in `acts_as_commentable'
…
Is there any simple replacement for this gem or way to monkey-patch this error so I can start up the app?
Looking over the forks, I found this one that appears to work for me using Rails 6.0.6 and Ruby 3.0.5.
https://github.com/alazycoder101/acts_as_commentable.git
I have not tested it extensively yet, but at least the basic functionality seems to be working for me. Hope this helps.
For clarity, to use that fork you would use the following line in your Gemfile:
gem 'acts_as_commentable', git: 'https://github.com/alazycoder101/acts_as_commentable.git'

Rails gcal4ruby gem uninitialized

I'm trying to create a Ruby on Rails web app that will sync with google calendar. I tried to use omniauth but it didn't work for me.
I found a rails gem that should do the job for me: gcal4ruby
But for now it isn't working.
I use the code:
#serv = Service.new
#serv.authenticate 'account#gmail.com', 'pass'
and got an error:
uninitialized constant UsersController::Service
In my gemfile using:
gem 'gcal4ruby', '0.5.5'
Gem was installed successfully after bundle install.
By trying to use similar gems I got the same error so I suppose that issue is something else.
I tried to use require "gcal4ruby" in my code and got error:
cannot load such file -- gcal4ruby
I'm using ruby 1.9.3 and rails 4.0.2.
Thanks for help.
Try:
require 'gcal4ruby'
include GCal4Ruby
Which mixes-in the Service class.
Note, that GCal4Ruby uses version 2 of the google calendar api which is deprecated and will not work after November-17th 2014.
Here is a great tutorial on getting a rails app working using omniauth.

Upgraded to rails 3.2 and AWS object is nolonger working, how come?

This hasn't got anything to do with paperclip, btw.
I've upgraded to rails 3.2 from a early version of rails 3.
I was using the AWS:S3 class to create buckets and what not.
The following code was working inside a model:
AWS::S3::Base.establish_connection!(:access_key_id => ...blah blah blah
I was also requiring the gem in the model like so:
require 'aws/s3'
However now I've upgraded and have ran all the updates on blunder, I'm getting the error:
uninitialized constant AWS::S3::Base
...when trying to establish a connection to S3.
Does anyone know what this is happening and how to fix it. Thanks.
I know you said it doesn't have to do with Paperclip but are you also using Paperclip in addition to the s3 gem in your app? I don't think newer versions of Paperclip depend on the aws-s3 gem anymore and instead depend on the aws-sdk gem.
Try replacing the aws-s3 gem with the aws-sdk gem.

Incompatability between Rails 2.3.5 and Omniauth

I use Rails 2.3.5 and want to use Omniauth however I can't get them to work together, as rails 2.3.5 requies Rack 1.0.1 and Omniauth (version 0.1.6) requires Rack 1.1
I deploy on Heroku so I don't believe I can hack into Rails and remove the hard dependency on version 1.0.1 of Rack.
Any help very much appreciated.
Paul
We had a similar issue. We were on Rails 2.3.4 and wanted to use OmniAuth (0.2.6). Unfortunately the only possible solution I've found so far is to upgrade to Rails 2.3.8 or later which runs on Rack 1.1 (the minimum required by OmniAuth) and then require OmniAuth like so:
# In config/environment.rb require 'omniauth' (or 'oa-<strategy_name>') before Rails::Initialize
require 'omniauth'
Rails::Initializer.run do |config|
...
# Add your own initializer for OmniAuth
# /config/initializers/omniauth.rb
ActionController::Dispatcher.middleware.use OmniAuth::Builder do
# your strategy provider logic
end
This was mostly groomed from this thread / links in it: http://groups.google.com/group/omniauth/browse_thread/thread/676fa835428e9c83
Unfortunately I'm in the middle of all of this right now so I can't promise this works fully as I'm using a custom strategy and haven't quite made it all the way to the end yet. Hopefully it provides some starting points for you to dig deeper if you're still stuck on this if nothing else.

Authlogic OpenID error: uninitialized constant OpenIdAuthentication::InvalidOpenId

Using authlogic 2.1.3, and authlogic-oid 1.0.4 I receive the following error as soon as rails hits a controller making a request to an OpenID provider:
uninitialized constant OpenIdAuthentication::InvalidOpenId
I also have the following installed:
rack-openid (0.2.1)
ruby-openid (2.1.7)
rails/open_id_authentication plugin
Gems in environment.rb are configured as such:
config.gem "authlogic"
config.gem "authlogic-oid", :lib => "authlogic_openid"
config.gem "ruby-openid", :lib => "openid"
Any suggestions would be appreciated, thank you.
rails/open_id_authentication plugin has been updated a few days ago and it breaks compatibility with the authlogic_openid gem (v=1.0.4).
Youl'll have to wait until someone fix the authlogic_openid gem (the issue)
I resolved that issue in my authlogic_openid fork, feel free to grab this commit: http://github.com/mreinsch/authlogic_openid/commit/9b802c347f5addebcbce945af3b5f80b3ee7b214
I was having the same trouble and I really wanted open-id with authlogic, so I copied an old version of plugin from one of Ryan Bates' railscasts apps.
Here's the link git#github.com:senthilnambi/open-id.git. Install it like normally and you should be fine.
Hope this helps. :)
Just like senthil provided, but with no # at URL:
script/plugin install git://github.com/senthilnambi/open-id.git
Then I erase the old (plugin/gem) who does not work
Going through the railscast 170. Troubleshooting lead me here. I tried authlogic_openid fork from last poster (mreinsch). This thankfully corrected openid_identifier error long enough for the regular login system to work, but not openid.
It's giving me an name error on the save method as identified in the block. This is apparently used to allow openid to get me to login.
Error Dump:
NameError in User sessionsController#create
uninitialized constant Rack::OpenID
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in `load_missing_constant'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing'
/Sites/authlogic_b/vendor/plugins/authlogic_openid/lib/authlogic_openid/session.rb:72:in `save'
/Sites/authlogic_b/app/controllers/user_sessions_controller.rb:8:in `create'

Resources