Short version: What are some good ways to allow the end user to define "processes" or sequentially executed CRUD operations in a fairly large project, so they can build templates for common processes (like creating 2 tickets for each new event posted automatically)? Something like Cucumber, but for CRUD operations..., or even Selenium?
Here's the situation:
I have inherited a very large project (the Spree eCommerce project), which I am modifying for a client. It's a very complex and very nicely done project. Most/all of the workflows for creating Products
, ProductGroups
, categories, etc., are very well defined, which means they could be automated.
So my client wants to be able to say "when I create a new Event
, I want it to create this too:
- Two tickets: 1 for $400, one for $500, which go on sale X and Y time after we create the event
- If it's this
Event
, also create this "early-bird" special."
This translates to create/save
-ing 4, maybe more, models in Spree: Event, Product, ProductGroup, ProductProperty
.
If I were to manually solve this edge case, I'd have to write quite a bit of code and do some serious refactoring (or copy-pasting) to make it so my client could create their tickets for each event they create. But what about the next case, "I want it to categorize each Ticket under this and that based on the event date
, location
, and meta_keywords
." Now I have to start all over again...
What I want to be able to do for them is allow them to configure all this stuff, so they can define:
- all kinds of default values to fill in product descriptions, prices, etc.
- to create X number of products based on the title of the Event.
- maybe some more things later.
The end result of all this is, Admin fills out one form, and it fills out 5 forms in the background (things that they don't need to know about necessarily, but need to be done).
I don't know the best or most common way to do this. I'm figuring it out as I go, but I'm sure many of you have some good ideas for this.
So the question(s) are:
What is the best way to make all of this configurable?
Spree has many of the methods I'd need buried inside of controllers, so it seems that a good practice would be to not include any methods in the controller, only references to methods in Modules (so you could reuse it everywhere). Unless you were allowed to chain multiple redirect_to
calls together, which you're not.
Are there any examples of something with this kind of configurability for the end user? Something like ERB templates for sequential CRUD operations?
Do I really need to code all of these cases manually?
The example above (of creating 2-3 tickets per event based on some property values) is pretty specific. Have any of you been able to create a system that's this configurable? The end goal would be for them to be like "oh, I've done this more than once, let's just make a template for this Event so next time it creates everything I did".
Just looking for some sort of push in the right direction, or some good examples on workflow automation. Something like Cucumber, but for CRUD operations...
Thanks!