0
votes

I'm using rails 3 with devise. I have a standard user signup form with name, email and password.

I need to create an additional signup form that lives within a pricing page where the user can signup with name, email, password and credit card information.

Should I be using the devise registrations controller or a new endpoint? I tried pointing to the devise registrations#create endpoint but with an invalid for submission the controller is redirecting to the wrong URL.

Any suggestions on how to best create an additional signup page with credit card subscription info included would be appreciated. Thanks

1
Maybe you could override the standard devise registration form and render the additional form fields if needed, and not show them if not needed? Normally this way the controller should work out-of-the box I think.Matthias

1 Answers

0
votes

In general you should create a new model related to user that stores all credit card information in it. Then you could create a specific controller action that handles the default user sign_up and includes the credit card info inside this new table. e.g:

inside new model's controller, UserCreditCardController.rb:

def sign_up_credit_card
    user = User.create(params[:name], params[:email] ....)
    UserCreditCard.create(user.id, params[:credit_card_number] ...)
    sign_in(user)
end

This way, not only you can solve your problem. But you can add support for multiple Credit Cards, without having to polute this information to user's model.