I have followed every step in the recommended tutorial (linked in the documentation of this gem) here. Whenever I click the button I created to send a user to Stripe to get their stripe info and update the database, I get an error. I am clicking the button while logged in as a user, and I have all the fields in my database.
undefined method 'provider' for nil:NilClass
Specifically, this line:
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def stripe_connect
@user = current_user
if @user.update_attributes({
provider: request.env["omniauth.auth"].provider,
uid: request.env["omniauth.auth"].uid,
access_code: request.env["omniauth.auth"].credentials.token,
publishable_key: request.env["omniauth.auth"].info.stripe_publishable_key
})
# anything else you need to do in response..
sign_in_and_redirect @user, :event => :authentication
set_flash_message(:notice, :success, :kind => "Stripe") if is_navigational_format?
else
session["devise.stripe_connect_data"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
def failure
# If we do get failures we should probably handle them more explicitly than just rerouting to root. To review in the future with colo
redirect_to root_path
end
end
I have followed every step in the recommended tutorial (linked in the documentation of this gem) here. Whenever I click the button I created to send a user to Stripe to get their stripe info and update the database, I get an error. I am clicking the button while logged in as a user, and I have all the fields in my database.
undefined method 'provider' for nil:NilClass
Specifically, this line:provider: request.env["omniauth.auth"].provider,
initializers/devise.rbI have these in my .env file.
routes.rb
devise_for :users, :controllers => { :omniauth_callbacks => "omniauth_callbacks" }
omniauth_callback_controller.rband the button in the view:
<%= link_to image_tag('icons/blue-on-light.png'), user_stripe_connect_omniauth_callback_path(:stripe_connect) %>
schema.rb