0
votes

I am building an ecommerce solution using spree to handle products/orders etc. I am having a little trouble figuring how to create spree entries through my signup controller. The user fills a form out and then it is supposed to:

1) create a new user object with addresses

2) create a new order for that user + add a subscription product to that order

3) Create a stripe customer and add a stripe plan

4) Redirect to a confirmation page.

I can't seem to find much in the way of documentation for integrating with spree from a custom rails setup (only overriding their templates).

The issue I am having is that I am not seeing the new user object being created. I pulled this code from the backend and modified it to create a new user when the signup form is submitted:

user_params = {"email" => emailAddress,"password"=> password}

spreeUser = Spree.user_class.new(user_params)

spreeUser.save

This isn't adding any new user to the DB. I have also tried through the api endpoint POST api/users but still no luck.

Is it possible to use spree in this way and if so what am I doing wrong!

1

1 Answers

0
votes

Spree does not have a user class built in. You need to either (1) use the Spree Auth Devise gem, (2) use another gem like regular Devise to create a user class or (3) create your own. If you do (2) or (3), you then set up Spree to recognize that user class.

This Spree documentation walks you through how to do just that.