What is the best way to reuse a controller’s actions and views?
Lets say I have an application that has controller:
SampleController<ApplicationController
This controller would be accessable from the following url
http:localhost:3000/sample/blah_action
I need to create another controller that has the actions of this
controller, plus some more actions of its own
If I created another controller: ImageController < SampleController
Then this url : http://localhost:3000/sample/image/blah_action would
take me to the ImageController if the actions exist exists in it.
however if the action doesn’t exist, it should use the parent’s
actions and views.
I has the same issue when I wanted a SOAP controller
(ActionWebService) to reuse my Restful logic in the normal
controllers.
Inheritance was not an option, because i needed logic from mulitple
Restful controllers (mixin would override shared method names, so that
didn’t work).
I ended up using a render_component statement (with response format
XML) from the SOAP Controller towards the Restful controller, which is
really ugly because that means I was actually pretending the SOAP
controller to be an external application. But it works fine en it
helps me keep my code DRY (but slower).
If anybody has a better idea to solve this please let me know.
Regards,
Bas
On Jan 25, 3:08 am, Nathan E. <rails-mailing-l…@andreas-
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.