Rails Facebook login works on local environment but not production -


facebook login works on localhost when push code server , try login error

completed 500 internal server error in 5ms  activerecord::unknownattributeerror (unknown attribute: name): app/models/confirmable.rb:20:in `initialize' app/models/user.rb:83:in `find_for_facebook_oauth' app/controllers/omniauth_callbacks_controller.rb:5:in `facebook' 

user.rb

 def self.find_for_facebook_oauth(auth, signed_in_resource=nil)   user = user.where(:provider => auth.provider, :uid => auth.uid).first   if user    return user   else    registered_user = user.where(:email => auth.info.email).first    if registered_user     return registered_user    else     user = user.create(name:auth.extra.raw_info.name,                           provider:auth.provider,                           uid:auth.uid,                           email:auth.info.email,                           password:devise.friendly_token[0,20],                         )    end    end   end 

omniauth_callbacks_controller.rb

def facebook       @user = user.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)        if @user.persisted?          sign_in_and_redirect @user, :event => :authentication #this throw if @user not activated   set_flash_message(:notice, :success, :kind => "facebook") if is_navigational_format?  else   session["devise.facebook_data"] = request.env["omniauth.auth"]   redirect_to new_user_registration_url  end end 

looking @ error, seems there no name attribute in users table. while creating user record passing non-existing attribute , getting error.

to resolve issue,

either add column users table called name by:

generating migration   rails generate migration addnametousers name:string running    rake db:migrate 

or

remove name attribute , value list of arguments passed user.create method.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -