Commit 8edccdce by Mathieu Martin

Make sure Paperclip doesn't raise an exception when using a numeric style name

parent f6e01b6b
...@@ -93,7 +93,7 @@ module Paperclip ...@@ -93,7 +93,7 @@ module Paperclip
# If the style has a format defined, it will return the format instead # If the style has a format defined, it will return the format instead
# of the actual extension. # of the actual extension.
def extension attachment, style_name def extension attachment, style_name
((style = attachment.styles[style_name.to_sym]) && style[:format]) || ((style = attachment.styles[style_name.to_s.to_sym]) && style[:format]) ||
File.extname(attachment.original_filename).gsub(/^\.+/, "") File.extname(attachment.original_filename).gsub(/^\.+/, "")
end end
......
...@@ -95,7 +95,7 @@ module Paperclip ...@@ -95,7 +95,7 @@ module Paperclip
@s3_permissions = set_permissions(@options[:s3_permissions]) @s3_permissions = set_permissions(@options[:s3_permissions])
@s3_protocol = @options[:s3_protocol] || @s3_protocol = @options[:s3_protocol] ||
Proc.new do |style, attachment| Proc.new do |style, attachment|
permission = (@s3_permissions[style.to_sym] || @s3_permissions[:default]) permission = (@s3_permissions[style.to_s.to_sym] || @s3_permissions[:default])
permission = permission.call(attachment, style) if permission.is_a?(Proc) permission = permission.call(attachment, style) if permission.is_a?(Proc)
(permission == :public_read) ? 'http' : 'https' (permission == :public_read) ? 'http' : 'https'
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment