开发者

sharing constant between models

I want to have constat defined in two models, but I don't want to repeat code. I've placed this constant in config/application.rb开发者_StackOverflow社区. Is that a good practice? Is there a better way to do that?


A better place to declare application constants would be in a .rb file in config/initializers folder. Declaring a constant in an initializer (or as you have done in config/application.rb) makes it available in ALL models/controllers/views in your application.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜