Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for Rails 3.1 #1

Merged
merged 1 commit into from
Jan 19, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/technoweenie/attachment_fu.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def image?(content_type)
end end


def self.extended(base) def self.extended(base)
base.class_inheritable_accessor :attachment_options base.class_attribute :attachment_options
base.before_destroy :destroy_thumbnails base.before_destroy :destroy_thumbnails
base.before_validation :set_size_from_temp_path base.before_validation :set_size_from_temp_path
base.after_save :after_process_attachment base.after_save :after_process_attachment
Expand Down Expand Up @@ -290,11 +290,11 @@ def create_or_update_thumbnail(temp_file, file_name_suffix, *size)
thumbnailable? || raise(ThumbnailError.new("Can't create a thumbnail if the content type is not an image or there is no parent_id column")) thumbnailable? || raise(ThumbnailError.new("Can't create a thumbnail if the content type is not an image or there is no parent_id column"))
find_or_initialize_thumbnail(file_name_suffix).tap do |thumb| find_or_initialize_thumbnail(file_name_suffix).tap do |thumb|
thumb.temp_paths.unshift temp_file thumb.temp_paths.unshift temp_file
thumb.send(:'attributes=', { thumb.assign_attributes({
:content_type => content_type, :content_type => content_type,
:filename => thumbnail_name_for(file_name_suffix), :filename => thumbnail_name_for(file_name_suffix),
:thumbnail_resize_options => size :thumbnail_resize_options => size
}, false) }, :without_protection => true)
callback_with_args :before_thumbnail_saved, thumb callback_with_args :before_thumbnail_saved, thumb
thumb.save! thumb.save!
end end
Expand Down Expand Up @@ -482,7 +482,7 @@ def resize_image_or_thumbnail!(img)
if defined?(Rails) && Rails::VERSION::MAJOR >= 3 if defined?(Rails) && Rails::VERSION::MAJOR >= 3
def callback_with_args(method, arg = self) def callback_with_args(method, arg = self)
if respond_to?(method) if respond_to?(method)
send(method, arg) send(method, arg)
end end
end end
# Yanked from ActiveRecord::Callbacks, modified so I can pass args to the callbacks besides self. # Yanked from ActiveRecord::Callbacks, modified so I can pass args to the callbacks besides self.
Expand Down