Sha256: 27b7d349ac34b045d40a33de82eedc333df3e3b509a31748ed2fe636d5a29155
Contents?: true
Size: 561 Bytes
Versions: 2
Compression:
Stored size: 561 Bytes
Contents
class Override < ActiveRecord::Base attr_accessible :context_name, :field_name, :field_value, :overrideable_id, :overrideable_type belongs_to :overrideable, :polymorphic => true validates :field_name, :presence => true validates :context_name, :presence => true validate :field_name_exists_on_associated_model def field_name_exists_on_associated_model klass = overrideable_type.constantize unless klass.attribute_names.include?(field_name) errors.add(:field_name, "must be an attribute of #{overrideable_type}") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
two_faced-0.0.2 | app/models/override.rb |
two_faced-0.0.2.alpha | app/models/override.rb |