Class: BigbluebuttonMetadata
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- BigbluebuttonMetadata
- Includes:
- ActiveModel::ForbiddenAttributesProtection
- Defined in:
- app/models/bigbluebutton_metadata.rb
Instance Method Summary collapse
-
#exclusion_of_name_in_reserved_metadata_keys ⇒ Object
metadata keys are only invalid when the metadata belongs to a room, metadata that will be used in a ‘create’ call TODO: a better solution for rails >= 3.1 validates :name, :exclusion => { :in => lambda do |m| if m.owner_type == “BigbluebuttonRoom” BigbluebuttonRails.configuration.metadata_invalid_keys.map(&:to_s) else [] end end }.
Instance Method Details
#exclusion_of_name_in_reserved_metadata_keys ⇒ Object
metadata keys are only invalid when the metadata belongs to a room, metadata that will be used in a ‘create’ call TODO: a better solution for rails >= 3.1 validates :name, :exclusion =>
:in => lambda do |m|
if m.owner_type == "BigbluebuttonRoom"
BigbluebuttonRails.configuration.metadata_invalid_keys.map(&:to_s)
else
[]
end
end
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/bigbluebutton_metadata.rb', line 30 def keys = if owner_type == "BigbluebuttonRoom" BigbluebuttonRails.configuration..map(&:to_s) else [] end if keys.include?(name) # use the same message rails would generate for :exclusion => :in msg = self.errors.(:name, :exclusion, {}) errors.add(:name, msg) end end |