This is a demo to show-case how to implement a service object.
You can also check my other demos here.
You can download this repo and see it working in localhost:3000
.
First, you should implement the logic in the controller and see it working.
Then, you should create the app/services
folder (if it doesn't exist yet) and create a PORO (Plain Old Ruby Object) to encapsule your logic.
It is good practice to have a method called call
to run your service object.
After this, it's all about calling this service object in your controller.
Good Luck and Have Fun
To know more: