What's the correct way to run one controller action from another controller action without an HTTP redirect?

后端 未结 6 618
无人及你
无人及你 2020-12-30 09:33

I\'d like to be able to dispatch from one controller action to another conditionally, based on a combination of query parameters and data in the database.

What I hav

6条回答
  •  不思量自难忘°
    2020-12-30 09:45

    If two controllers are trying to do the same thing, there's a very good chance this should be in a model. Take a good look at your design and -- I'm sorry I don't know your experience level with MVC -- read up on thin controller techniques:

    http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model http://www.robbyonrails.com/articles/2007/06/19/put-your-controllers-on-a-diet-already http://andrzejonsoftware.blogspot.com/2008/07/mvc-how-to-write-controllers.html

    If the problem is that you need the other controller to do the render, then maybe the route should have pointed there to begin with, and still the skinny controller technique should save the day.

提交回复
热议问题