RailsApps / rails-stripe-membership-saas

An example Rails 4.2 app with Stripe and the Payola gem for a membership or subscription site.
http://railsapps.github.io/rails-stripe-membership-saas
1.14k stars 232 forks source link

NoMethodError at /users/sign_in #74

Closed liquidtrends closed 9 years ago

liquidtrends commented 11 years ago

I am at the point of the tutorial where I integrate the JS with stripe. I have tested the signup and the console messages pass for me.

When I move forward with "Add JavaScript for Form Processing" and register a new user, I am presented with the following error after hitting the submit button:

NoMethodError at /users/sign_in undefined method `name' for nil:NilClass

after_sign_in_path_for app/controllers/application_controller.rb, line 9

4 rescue_from CanCan::AccessDenied do |exception| 5 redirect_to root_path, :alert => exception.message 6 end 7 8 def after_sign_in_path_for(resource) 9 case current_user.roles.first.name 10 when 'admin' 11 users_path 12 when 'silver' 13 content_silver_path 14 when 'gold'

DanielKehoe commented 11 years ago

Looks like your app doesn't have a role set for the current_user. The role corresponds to the plan selected by the user. Check to see if the plan is set.

liquidtrends commented 11 years ago

Thanks. Can you expand on this? I went through the code and didn't see anything that would be missing...

DanielKehoe commented 11 years ago

I suggest cloning the reference implementation from the repo and comparing with what you have.

MarkDBlackwell commented 11 years ago

AFAIR, in order to fix this error I had to do either rake db:migrate or rake db:seed per README section Set the Database.

DanielKehoe commented 9 years ago

There is a new version of this application for Rails 4.2 using the Payola gem.