diff --git a/README b/README index bbac4f5f..f630c207 100644 --- a/README +++ b/README @@ -50,6 +50,7 @@ has_attachment(options = {}) :processor # Sets the image processor to use for resizing of the attached image. # Options include ImageScience, Rmagick, and MiniMagick. Default is whatever is installed. :uuid_primary_key # If your model's primary key is a 128-bit UUID in hexadecimal format, then set this to true. + :association_options # attachment_fu automatically defines associations with thumbnails with has_many and belongs_to. If there are any additional options that you want to pass to these methods, then specify them here. Examples: diff --git a/lib/technoweenie/attachment_fu.rb b/lib/technoweenie/attachment_fu.rb index a91dca9a..a041c615 100644 --- a/lib/technoweenie/attachment_fu.rb +++ b/lib/technoweenie/attachment_fu.rb @@ -103,7 +103,11 @@ def has_attachment(options = {}) end attachment_options[:path_prefix] = attachment_options[:path_prefix][1..-1] if options[:path_prefix].first == '/' - with_options :foreign_key => 'parent_id' do |m| + association_options = { :foreign_key => 'parent_id' } + if attachment_options[:association_options] + association_options.merge!(attachment_options[:association_options]) + end + with_options(association_options) do |m| m.has_many :thumbnails, :class_name => "::#{attachment_options[:thumbnail_class]}" m.belongs_to :parent, :class_name => "::#{base_class}" unless options[:thumbnails].empty? end