lib/paperclip/storage/database.rb in paperclip_database-3.0.0 vs lib/paperclip/storage/database.rb in paperclip_database-3.1.0
- old
+ new
@@ -102,11 +102,11 @@
@paperclip_file_model.table_name = @options[:database_table] || name.to_s.pluralize
@paperclip_file_model.validates_uniqueness_of :style, :scope => instance.class.table_name.classify.underscore + '_id'
case ActiveModel::VERSION::MAJOR
when 3, 4
@paperclip_file_model.scope :file_for, lambda {|style| @paperclip_file_model.where('style = ?', style) }
- when 5
+ when 5,6
@paperclip_file_model.scope :file_for, lambda {|style| where('style = ?', style) }
else
raise "ActiveModel version #{ActiveModel::VERSION::STRING} is not supported (yet)"
end
end
@@ -195,12 +195,10 @@
ActiveRecord::Base.logger.info("[paperclip] Writing files for #{name}")
@queued_for_write.each do |style, file|
case ActiveModel::VERSION::MAJOR
when 3
paperclip_file = instance.send(@paperclip_files_association_name).send(:find_or_create_by_style, style.to_s)
- when 4
- paperclip_file = instance.send(@paperclip_files_association_name).send(:find_or_create_by, style: style.to_s)
- when 5
+ when 4,5,6
paperclip_file = instance.send(@paperclip_files_association_name).send(:find_or_create_by, style: style.to_s)
else
raise "ActiveModel version #{ActiveModel::VERSION::STRING} is not supported (yet)"
end
paperclip_file.file_contents = file.read