开发者

calling actions in other controller

开发者 https://www.devze.com 2023-01-19 04:55 出处:网络
I have a controller called twits controller .. here i have few actions to communic开发者_如何转开发ate with the 3rd party API.. it has few actions to authenticate and few actions to get some values wi

I have a controller called twits controller .. here i have few actions to communic开发者_如何转开发ate with the 3rd party API.. it has few actions to authenticate and few actions to get some values with the help of API. Now i have another controller called home and in the index page of this controller i have to call the actions of the twits controller and this should happen while the index page is getting rendered. Please advice.


Calling actions of one controller into another is generally a bad idea. You should extract the functionality into a module or a class and use it in both controllers.

So in your case, you should be writing a wrapper class for communicating with the 3rd party API and then use that wrapper. Note that this wrapper class not an abstracted wrapper for general use, but functionality that your legacy code provides, which you intend to reuse.

Hope this helps. If it isn't, try posting some code and maybe I can suggest something more.

0

精彩评论

暂无评论...
验证码 换一张
取 消