Question

I'm having some trouble getting Stripe up and running in my Rails app. When I try to access my signup form in my local environment I get this error:

undefined method `card_number'

The corresponding code for my view is as follows:

<%= f.label :card_number, "Credit Card Number" %>
<%= f.text_field :card_number %>

Because I'm getting an error for the card number, I also know that when I fix the error for the card number that I will get errors for the CVV code and card expiration date. I realize that I'm not supposed to save any credit card information to my database, so I don't have any information in my model with regard to credit card information. The only database migration that I have run was setting up a column in my users table for the stripe customer id token.

Any help you can provide for me in getting Stripe up and working would be greatly appreciated!

Was it helpful?

Solution

Calling f.text_field :card_number expects an attribute (real or virtual) on the f.object... So, instead have this:

=label_tag :credit_card
=text_field_tag :credit_card

These won't be tied to your model, but will exist on the form .... you can then get at them via javascript (which is the whole point, really).

You'll combine that with:

=f.hidden_field :card_token

and actually store the card_token for use later.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top