Add an ':association_options' option for passing additional options to the association creation methods.
Signed-off-by: rick <technoweenie@gmail.com>
This commit is contained in:
Родитель
2c164b6854
Коммит
45b0e31c89
1
README
1
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:
|
||||
|
|
|
@ -103,7 +103,11 @@ module Technoweenie # :nodoc:
|
|||
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче