开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜