Reputation: 2385
I'm building an application that among other things allows users to upload documents. I have the basic create/view actions working just fine, but i'd like to reuse this action in other places.
I want to know if anyone has a pointer for how to do this. There doesn't seem to be a very good way of doing this.
Here are a few ways i've considered:
Thanks
--Matthias
Upvotes: 0
Views: 539
Reputation: 35864
I don't care for the extending controller method. In fact, I avoid inheritance when possible. I'd rather put the common code in a service class and reuse it that way.
Upvotes: 5
Reputation: 597016
You can use a base controller class, and place the common functionality there. Then extend the base controller and call the method from other action methods.
Upvotes: 1