igor-alexandrov/paperclip-aws — Issue #8: ENV based configuration breaks initialization.
Author: serek
Created: 2012-02-03 16:37:20+00:00
State: open

Hello,

Example:

# File
has_attached_file :data,
:storage => :aws,
:s3_credentials => {
:access_key_id => ENV['S3_KEY'],
:secret_access_key => ENV['S3_SECRET'],
:endpoint => 's3-eu-west-1.amazonaws.com'
},
:bucket => ENV['S3_BUCKET'],
:s3_permissions => :public_read,
:s3_protocol => 'http',
:path => ":class/:id/:basename_:style.:extension",
:default_url => "/:class/:attachment/missing_:style.png"

Stack trace (I've putted this file into my own lib for debugging):

NoMethodError: undefined method `s3_credentials' for #
from /home/marcin/repos/sample_project/lib/paperclip-aws.rb:22:in `block in extended'
from /home/marcin/repos/sample_project/lib/paperclip-aws.rb:19:in `instance_eval'
from /home/marcin/repos/sample_project/lib/paperclip-aws.rb:19:in `extended'

What options got:

(rdb:1) ap @options
{
:convert_options => {},
:default_style => :original,
:default_url => "/:class/:attachment/missing_:style.png",
:restricted_characters => /[&$+,\/:;=?@<>\[\]\{\}\|\\\^~%# ]/,
:hash_data => ":class/:attachment/:id/:style/:updated_at",
:hash_digest => "SHA1",
:interpolator => Paperclip::Interpolations,
:only_process => [],
:path => ":class/:id/:basename_:style.:extension",
:preserve_files => false,
:processors => [
[0] :thumbnail
],
:source_file_options => {},
:storage => :aws,
:styles => {},
:url => "/system/:attachment/:id/:style/:filename",
:url_generator => Paperclip::UrlGenerator < Object,
:use_default_time_zone => true,
:use_timestamp => true,
:whiny => true,
:validations => [],
:s3_credentials => {
:access_key_id => "xxx",
:secret_access_key => "xxx",
:endpoint => "s3-eu-west-1.amazonaws.com"
},
:bucket => "xxx",
:s3_permissions => :public_read,
:s3_protocol => "http"
}

So @options are basically Hash with symbols.