Ruby on Rails Monday, August 26, 2013

On 26 August 2013 21:39, Rekha Benada <rekha.benada@gmail.com> wrote:
> Hi,
>
> I am trying to add linkedin login feature in my rails application using
> omniauth gem..I used omniauth gem for Fb login and it's working fine..but
> it's not working for linkedin login
>
> this is my code
>
> /model/user.rb
>
> class User < ActiveRecord::Base
> attr_accessible :name, :oauth_expires_at, :oauth_token, :provider, :uid
>
>
>
> def self.from_omniauth(auth)
> where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user|
> user.provider = auth.provider
> user.uid = auth.uid
> user.name = auth.info.name
> user.oauth_token = auth.credentials.token
> user.oauth_expires_at = Time.at(auth.credentials.expires_at)
> user.save!
> end
> end
> ...
> Error:
>
> TypeError in SessionsController#create
>
> can't convert nil into an exact number
>
>
> Application Trace | Framework Trace | Full Trace
>
> app/models/user.rb:12:in `at'

You have not told us which line this is, but I presume it is
user.oauth_expires_at = Time.at(auth.credentials.expires_at)
What is the value of auth.credentials.expires_at, which seems to be
the value it is complaining about?

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvyNkRXCXvqwEaBxOEr%2BRG3PVNNbhWX6VwRY%3DPw%3DEBrFw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment