开发者

Rails 3: Is that possible to expose Controller's method to model?

开发者 https://www.devze.com 2023-03-07 02:15 出处:网络
helper_method exposes Controller\'s method to a vie开发者_StackOverfloww. Is that possible to expose Controller\'s method to a model ?The MVC model is trying to separate code. So if you wanna access

helper_method exposes Controller's method to a vie开发者_StackOverfloww.

Is that possible to expose Controller's method to a model ?


The MVC model is trying to separate code. So if you wanna access code in controllers from model. This means design wise, you may be wrong somewhere. If you wanna share code between controllers and models, it is suggested to put it in to library.


It's possible, but in most cases this is a very, very bad idea.

You may want to define the method in the model, and call it in the controller's action.

Without knowing what you want to achieve, it's hard to give you more detailed instructions.

0

精彩评论

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