app/models/locomotive/theme_asset.rb in locomotive_cms-2.1.0 vs app/models/locomotive/theme_asset.rb in locomotive_cms-2.1.1

- old
+ new

@@ -6,15 +6,15 @@ ## extensions ## include Extensions::Asset::Types ## fields ## field :local_path - field :content_type - field :width, type: Integer - field :height, type: Integer - field :size, type: Integer - field :folder, default: nil + field :content_type, type: Symbol + field :width, type: Integer + field :height, type: Integer + field :size, type: Integer + field :folder, default: nil field :checksum mount_uploader :source, ThemeAssetUploader, mount_on: :source_filename, validate_integrity: true ## associations ## @@ -168,10 +168,15 @@ self.changed_attributes['source_filename'] = nil # delete the old file end end def content_type_can_not_change - self.errors.add(:source, :extname_changed) if self.persisted? && self.content_type_changed? + if self.persisted? + # FIXME: content type used to be a String + if self.content_type_was.to_sym != self.content_type + self.errors.add(:source, :extname_changed) + end + end end def calculate_checksum begin self.checksum = Digest::MD5.hexdigest(self.source.read)