假设我有一组相当小的(~3-10)和静态的类别。Category
创建专用模型或使用类似哈希的结构之间的权衡是什么?例如...
class Something < ActiveRecord::Base
# Using a Category model
belongs_to :category
default_scope :include => :category
# Using a hash-like structure
CATEGORIES = ["A", "B", "C", "D", "E"]
def category
CATEGORIES[category_id]
end
# validate_inclusion_of :category_id as appropriate
...
end