lib/para/ext/paperclip.rb in para-0.5.3 vs lib/para/ext/paperclip.rb in para-0.5.4

- old
+ new

@@ -26,11 +26,12 @@ if value == '1' removed_attachments << attachment_name # Notify ActiveRecord that the model has changed so nested models # get to run validation hooks and attachments are cleared - send(:"#{ attachment_name }_file_name_will_change!") + column_name = attribute_container_column_for(attachment_name) + send(:"#{ column_name }_will_change!") end end @klass.send :define_method, :"remove_#{ attachment_name }" do |value| removed_attachments.include?(attachment_name) ? '1' : nil @@ -57,9 +58,21 @@ removed_attachments.clear end @klass.send(:before_validation, :clear_removed_attachments) + end + + @klass.send(:define_method, :attribute_container_column_for) do |attachment_name| + attribute_name = "#{ attachment_name }_file_name" + + if self.class.columns.any? { |column| column.name == attribute_name } + return attribute_name + end + + stored_attribute = self.class.stored_attributes.each do |key, fields| + return key if fields.include?(attribute_name.to_sym) + end end end end end end