lib/has-attached.rb in has-attached-0.2.3 vs lib/has-attached.rb in has-attached-0.2.4
- old
+ new
@@ -32,12 +32,14 @@
def has_attached(name, options = {})
options[:url] ||= "/attachments/:class/:id/:attachment/:style/:basename.:extension"
options[:path] ||= ":rails_root/public/attachments/:class/:id/:attachment/:style/:basename.:extension"
-
- @all_styles ||= (YAML.load_file(Rails.root.join("config", "styles.yml")) rescue {"styles" => {}})["styles"]
- options[:styles] = @all_styles.fetch(self.name.underscore, {}).fetch(name.to_s, {}).symbolize_keys
+
+ unless options[:styles]
+ @all_styles ||= (YAML.load_file(Rails.root.join("config", "styles.yml")) rescue {"styles" => {}})["styles"]
+ options[:styles] = @all_styles.fetch(self.name.underscore, {}).fetch(name.to_s, {}).symbolize_keys
+ end
if Rails.env.production? && Rails.application.config.respond_to?(:upload_attachments_to_s3) && Rails.application.config.upload_attachments_to_s3
options[:storage] = 's3'
options[:s3_credentials] = Rails.root.join("config", "s3.yml")
options[:path] = "/attachments/:class/:id/:attachment/:style/:basename.:extension"