-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error message when loading "Sign Up" View #127
Comments
Please wait a very short while ..
|
So a few possibilities. Most likely your resource doesn't have a plan. You can check by inspecting the resource as that page is loaded. On Apr 24, 2015 5:48 PM, DNSH [email protected] wrote: I have cloned the app from the repo and have run "rails s" The homepage loads, but then when I click "Sign Up" I receive the following error message: NoMethodError at /users/sign_up: undefined method `plan_class' for nil:NilClass, The output says the error is occurring on line 8 in "app/views/devise/registrations/new.html.erb": 'data-payola-plan-type' => resource.plan.plan_class, I was wondering how I should proceed? Thanks — |
I can tell you this line is correct : 'data-payola-plan-type' => resource.plan.plan_class, You can see more of the set up for this helper here : |
I doubt this has anything to do with stripe. Can you open up your rails console and type Let me know the result. If it doesn't output |
When we get to this point in the Pull Requests of more tests merged to master, app/models/plan.rb
Has changed to this :
Feel free to make that one change, and see what happens. The reason this vaidation can be removed is this method definition in this file below, app/models/user.rb endIf you have any problem after that, let me know what it is.
|
The membership app is being prepared for Rails 5. |
@kathyonu , forgive me if I'm missing something. But how does the inclusion validation validates :stripe_id, inclusion: { in: Plan.pluck('DISTINCT stripe_id'),
message: "not a valid subscription plan" } have anything to do with the after initialize call of: self.plan ||= Plan.last They are doing completely different things. If the user doesn't select a default plan, the users plan is set to Whereas the inclusion validation runs after the creation of a |
@tmock12 : bowing in your presence as an early contributor .. I can explain how, while working up the tests for our in service production app, and now doing the same for the rails-stripe-membershp-saas update to Rails 4.2.1, that the pluck code was among the bugaboos that ran me round in circles. I thought, by virtue of the plan being set when the visitor arrives at the sign_up window .. that validation is pointless. That for me, is the connection. And why removing it was okay, and why removing it would be safe, and allow the app to fire up. Am I amiss ? in this connection, though nebulous ? Eye am always open to correction. |
@kathyonu I tried removing the lines you suggested from app/models/plan.rb but the error still persists @tmock12 I tried your suggestion and the output is below: Loading development environment (Rails 4.2.1) |
@tmock12 , Look at the error :
So, the question becomes, is the Stripe API Key set in your environmental variables ? Normal answer to not having an api key set would be this :
You also want to make sure your STRIPE_PUBLISHABLE_KEY is set, so look for that one too. development: Add those two if need be, close the file, and restart your server and or console. $ export STRIPE_API_KEY=sk_test_( fill in your real key sequence ) Now try it. |
Sorry I was driving all day and don't have much time to respond. But yes the problem is your API key isn't set, which is why the plans aren't being set, which is causing the error on the registrations new page. like @DNSH reported the error is on line 8 of the registrations/new page. So to fix this its as simple as providing your API keys and rerunning You can't just start your server after providing your API keys as |
@DNSH please let us know if setting the API keys and running |
@tmock12 , How correct you are. @DNSH , I missed the step I like to do often while development changes occur ..
If that does not work, you instantly know you have a problem. I use the reset command often because it covers all of the database creations, Let us leave no stone unturned here ..
If the end of yours does not look like that, put these four lines in your db/seeds.rb file :
Now enter the console, then enter this command
You now have your Plan available to you. These commands now work in the console :
Proofs :
How is it working now, @DNSH ? Please Note : If you do not have the database migrated and seeded ..
Now go into the console and run the command :
To fix this, run either
I am not showing results for brevity, they are same as above.
There you have it.
|
No reply from @DNSH so I am closing this issue and assuming it was resolved to his satisfaction. |
I had the same error, running these two commands in the terminal solved the issue for me: $ export STRIPE_API_KEY=sk_test_( fill in your real key sequence ) Think it was an issue with me not setting the environment variables properly using the Figaro gem. |
May I refer you to one of the first tests I put in place when working with Stripe in an app new to me : spec/stripe/stripe_confiig_spec.rbdescribe "Config Variables" do describe "STRIPE_API_KEY" do describe "STRIPE_PUBLISHABLE_KEY" do end I just pushed this commit showing the same tests : https://github.com/kathyonu/rails-stripe-membership-saas/blob/20150520usersignup/spec/stripe/stripe_config_spec.rb https://github.com/kathyonu/rails-stripe-membership-saas/blob/20150520usersignup/spec/stripe/stripe_config_spec.rb
|
Thanks @kathyonu. The app is working for me locally, but when I push to Heroku it is unable to migrate the databases due to the following error:
I also see the following error in the Heroku logs:
I've checked the Heroku dashboard and the Stripe API and Publishable keys have been set, so I'm not sure what is wrong. |
You can set your ENV variables with a heroku command.
You can read more about it here: http://railsapps.github.io/rails-environment-variables.html |
@archonic Thanks - I checked my heroku dashboard (e.g. http://dashboard.heroku.com) and the ENV variables, but for whatever reason it was only when following your heroku commands that the app worked in production. Problem solved! |
@benrmatthews , i presume that means you have run this command in your terminal, $ heroku config --app yourappname from your app’s directory, and your Stripe Keys are showing ? If not, set them both with : $ heroku config:add STRIPE_API_KEY=sk_live_yourlongstring STRIPE_PUBLISHABLE_KEY=pk_live_yourlongstring Or separately : $ heroku config:add STRIPE_API_KEY=sk_live_yourlongstring Also, I don’t think this has anything to do with it, but .. $ rake rails:update:bin Taken from : Rails-applications-health-codes.md : https://gist.github.com/kathyonu/c9ef8190e50422bc0edc
|
I cannot create a plan in Heroku. I am able to successfully create run rake db:seed, create plans, and sign up users in development mode. In production on heroku I am unable to create a plan. I receive the same errors others are getting. For example: irb(main):001:0> s1 = Plan.new(name:'Silver', stripe_id:'silver', interval:'monthly', amount: 900) I set my test keys in heroku using the previous answer: I am not able to run db:drop because I have important information in the database. I am using the following gems which I believe to be the most recent:
I removed the following line from the model Plan.rb: Where the are the Bearer authorization header environmental variables called from by Payola Payments? Help troubleshooting this problem as to why it works in development but not on Heroku would be wonderful. Please let me know if you need any other information. Thanks, Ty |
I read the Stripe documentation and set the Heroku ENV variables using: heroku config:set PUBLISHABLE_KEY=pk_test_xxxxxxxxxxxxxxxxx SECRET_KEY=xxxxxxxxxxxxxxxxxxx Now I am getting a new error that says: One step closer =) |
mrusson's comment on Apr 15 worked: |
I have cloned the app from the repo and have run "rails s"
The homepage loads, but then when I click "Sign Up" I receive the following error message:
NoMethodError at /users/sign_up: undefined method `plan_class' for nil:NilClass,
The output says the error is occurring on line 8 in "app/views/devise/registrations/new.html.erb":
'data-payola-plan-type' => resource.plan.plan_class,
I was wondering how I should proceed? Thanks
The text was updated successfully, but these errors were encountered: