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.
精彩评论