Note that there are some explanatory texts on larger screens.

plurals
  1. POI am using rails cast omniauth and i get this error
    primarykey
    data
    text
    <p>I am using Mongodb as database in rails and i got error when using /auth/linkedin/callback</p> <p>NoMethodError in AuthenticationsController#create undefined method []' for nil:NilClass Rails.root: /home/prem/Music/heronhrm Application Trace | Framework Trace | Full Trace app/models/user.rb:57:in apply_omniauth' app/controllers/authentications_controller.rb:19:in `create'</p> <p>Also when i remove <code>self.email = omniauth['user_info']['email'] if email.blank?</code> from usermodel then the validation errors arises in </p> <p>users/sign_up Email can't be blank I want to implement for twitter,linkdin and facebook. </p> <p>my authentication.rb </p> <pre><code> class Authentication include Mongoid::Document belongs_to :user field :user_id, :type =&gt; String field :provider, :type =&gt; String field :uid, :type =&gt; String def self.find_by_provider_and_uid(provider, uid) where(provider: provider, uid: uid).first end end </code></pre> <p>my user model is like this</p> <pre><code>def apply_omniauth(omniauth) self.email = omniauth['user_info']['email'] if email.blank? authentications.build(:provider =&gt; omniauth['provider'], :uid =&gt; omniauth['uid']) end def password_required? (authentications.empty? || !password.blank?) &amp;&amp; super end </code></pre> <p>My authentications controller is like this</p> <pre><code> class AuthenticationsController &lt; ApplicationController def index @authentications = current_user.authentications if current_user end def create omniauth = request.env["omniauth.auth"] authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid']) if authentication flash[:notice] = "Signed in successfully." sign_in_and_redirect(:user, authentication.user) elsif current_user current_user.authentications.create!(:provider =&gt; omniauth['provider'], :uid =&gt; omniauth['uid']) flash[:notice] = "Authentication successful." redirect_to authentications_url else user = User.new user.apply_omniauth(omniauth) if user.save flash[:notice] = "Signed in successfully." sign_in_and_redirect(:user, user) else session[:omniauth] = omniauth.except('extra') redirect_to new_user_registration_url end end end def destroy @authentication = current_user.authentications.find(params[:id]) @authentication.destroy flash[:notice] = "Successfully destroyed authentication." redirect_to authentications_url end protected # This is necessary since Rails 3.0.4 # See https://github.com/intridea/omniauth/issues/185 # and http://www.arailsdemo.com/posts/44 def handle_unverified_request true end end </code></pre> <p>My registration controller is like this</p> <pre><code>class RegistrationsController &lt; Devise::RegistrationsController def create super session[:omniauth] = nil unless @user.new_record? end private def build_resource(*args) super if session[:omniauth] @user.apply_omniauth(session[:omniauth]) @user.valid? end end end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload