akkdio / sales

just trying the api for stripe out
0 stars 0 forks source link

AASM causing errors #4

Open akkdio opened 10 years ago

akkdio commented 10 years ago

Trying the AASM gem from the book on page 57 and having issues getting the charge_card method to fire. This is my initial thought since the errors coming back (see below) are saying complaining about not having and attribute. I have not been through the code line by line with a fine tooth comb to see if there is typo somewhere but I have commented out the attribute calls in the sales create method and it seems that the call to stripe.charge is not happening. Here is the error with this :

ActiveRecord::UnknownAttributeError in PaymentsController#create

unknown attribute: amount

Incidently the app lives on heroku:
https://morning-earth-2357.herokuapp.com

But it has these issues and more since I am not strictly adhering to the book. Partly because the book has errors and partly because it lacks a complete code list and is only given in snippets and that is bad news bears for the noobs.

lenn4rd commented 10 years ago

I found Mastering Modern Payment yesterday and was looking for some more sample code, that's how I found your repository. Sometime ago I played with Stripe a bit, nothing serious, but the code examples I found back then where mostly outdated or badly written. When I read that in the book the author is using states I thought his approach might be more robust than the others I've found online.

So, I checked out your code and I think I fixed the issues, at least for purchasing an item. The error you mention above (and a few others that will follow when the first one is fixed) comes from accessing a variable that's named wrong. Three files had errors in them and they're actually printed that way in the sample chapter from that book. It doesn't give a version number, maybe it's from version 1.41 as well.

Have a look at my commit if you want: https://github.com/lenn4rd/sales/commit/103f58a78bc684835c4882c445d2da55666a8e99