Rails 3.1: Model Constant in initializer causes warning
I have monkey patched the Tag class of the ActsAsTaggableOn plugin in an an initializer. All works fine, however I get a warning for a constant I added to Tag:
config/in开发者_运维技巧itializers/acts_as_taggable_on_extensions.rb:
class Tag < ActiveRecord::Base
... some stuff ...
TAG_TYPES = [:a, :b, :c]
... some more stuff ....
end
The warning is: config/initializers/acts_as_taggable_on_extensions.rb:136: warning: already initialized constant TAG_TYPES
How can I get rid of this warning?
I'm on ruby 1.9.2, Rails 3.1 rc4.
Try this:
TAG_TYPES ||= [:a, :b, :c]
You can add your own Tag Types by adding them to the TAG_TYPES array.
TAG_TYPES << :a << :b << :c
TAG_TYPES.uniq!
精彩评论