- with_options :foreign_key => 'parent_id' do |m|
- m.has_many :thumbnails, :class_name => attachment_options[:thumbnail_class].to_s
- m.belongs_to :parent, :class_name => base_class.to_s
+ 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
+
+ storage_mod = Technoweenie::AttachmentFu::Backends.const_get("#{options[:storage].to_s.classify}Backend")
+ include storage_mod unless included_modules.include?(storage_mod)
+
+ case attachment_options[:processor]
+ when :none, nil
+ processors = Technoweenie::AttachmentFu.default_processors.dup
+ begin
+ if processors.any?
+ attachment_options[:processor] = processors.first
+ processor_mod = Technoweenie::AttachmentFu::Processors.const_get("#{attachment_options[:processor].to_s.classify}Processor")
+ include processor_mod unless included_modules.include?(processor_mod)
+ end
+ rescue Object, Exception
+ raise unless load_related_exception?($!)
+
+ processors.shift
+ retry