panzi
panzi

Reputation: 7701

Rails 2.3.x: Call other controller from within a controller

Is it somehow possible to call another controller's action from within a controller? redirect_to is not what I need, because I've stored the request information (path, params, referer, xhr, ...) of another request and want to execute it now. Basically an exec for controller actions would be what I need. Simply instantiating the controller, setting the needed instance variables and calling the action is not enough, because this does not invoke the right filters and error handlers.

Upvotes: 0

Views: 294

Answers (1)

jesse reiss
jesse reiss

Reputation: 4579

No. You can't do this. This is why with the MVC pattern you hear people recommend "skinny controllers".

Move the logic down into the models as much as possible. Then it's easy to share across controllers. Or you can try moving the similar actions into a shared controller so that they can share behaviour.

Upvotes: 2

Related Questions