I want to create a ruby on rails app, which provides an api and also a portal. Consider that we can create users and lets say todo entries via the api and the portal as well. To make it DRY I want to use the api methods, within the other controllers. So when the user creates a todo entry via the portal, the business logic of the corresponding api controller should be executed instead of copying the code from that controller to the todo controller. Also I do want a separate api controller, since other clients (like mobile phones) should call a certain endpoint (like %BASE_URI%/api/rest/v1/...) instead of the different controllers. Is that possible and are there any best practises?
Best regards dasheck