Skip to content

Commit

Permalink
now pulls S3_BUCKET config from the environment, or the s3.yml file
Browse files Browse the repository at this point in the history
  • Loading branch information
jgilliam committed Dec 4, 2009
1 parent 82bc4d5 commit ae10c0b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions app/models/government.rb
Expand Up @@ -18,23 +18,23 @@ class Government < ActiveRecord::Base

has_attached_file :logo, :styles => { :icon_96 => "96x96#", :icon_140 => "140x140#", :icon_180 => "180x180#", :medium => "450x" },
:storage => :s3, :s3_credentials => S3_CONFIG,
:path => ":class/:attachment/:id/:style.:extension", :bucket => ENV['DOMAIN']
:path => ":class/:attachment/:id/:style.:extension", :bucket => S3_CONFIG["bucket"]

validates_attachment_size :logo, :less_than => 5.megabytes
validates_attachment_content_type :logo, :content_type => ['image/jpeg', 'image/png', 'image/gif']

belongs_to :buddy_icon_old, :class_name => "Picture"
has_attached_file :buddy_icon, :styles => { :icon_24 => "24x24#", :icon_48 => "48x48#", :icon_96 => "96x96#" },
:storage => :s3, :s3_credentials => S3_CONFIG, :default_url => "/images/buddy_:style.png",
:path => ":class/:attachment/:id/:style.:extension", :bucket => ENV['DOMAIN']
:path => ":class/:attachment/:id/:style.:extension", :bucket => S3_CONFIG["bucket"]

validates_attachment_size :buddy_icon, :less_than => 5.megabytes
validates_attachment_content_type :buddy_icon, :content_type => ['image/jpeg', 'image/png', 'image/gif']

belongs_to :fav_icon_old, :class_name => "Picture"
has_attached_file :fav_icon, :styles => { :icon_16 => "16x16#" },
:storage => :s3, :s3_credentials => S3_CONFIG, :default_url => "/favicon.png",
:path => ":class/:attachment/:id/:style.:extension", :bucket => ENV['DOMAIN']
:path => ":class/:attachment/:id/:style.:extension", :bucket => S3_CONFIG["bucket"]

validates_attachment_size :fav_icon, :less_than => 5.megabytes
validates_attachment_content_type :fav_icon, :content_type => ['image/jpeg', 'image/png', 'image/gif']
Expand Down
2 changes: 1 addition & 1 deletion app/models/partner.rb
Expand Up @@ -8,7 +8,7 @@ class Partner < ActiveRecord::Base

has_attached_file :logo, :styles => { :icon_96 => "96x96#", :icon_140 => "140x140#", :icon_180 => "180x180#", :medium => "450x" },
:storage => :s3, :s3_credentials => S3_CONFIG,
:path => ":class/:attachment/:id/:style.:extension", :bucket => ENV['DOMAIN']
:path => ":class/:attachment/:id/:style.:extension", :bucket => S3_CONFIG["bucket"]

validates_attachment_size :logo, :less_than => 5.megabytes
validates_attachment_content_type :logo, :content_type => ['image/jpeg', 'image/png', 'image/gif']
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Expand Up @@ -46,7 +46,7 @@ class User < ActiveRecord::Base
belongs_to :picture
has_attached_file :buddy_icon, :styles => { :icon_24 => "24x24#", :icon_48 => "48x48#", :icon_96 => "96x96#" },
:storage => :s3, :s3_credentials => S3_CONFIG, :default_url => "/images/buddy_:style.png",
:path => ":class/:attachment/:id/:style.:extension", :bucket => ENV['DOMAIN']
:path => ":class/:attachment/:id/:style.:extension", :bucket => S3_CONFIG["bucket"]

validates_attachment_size :buddy_icon, :less_than => 5.megabytes
validates_attachment_content_type :buddy_icon, :content_type => ['image/jpeg', 'image/png', 'image/gif']
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Expand Up @@ -37,5 +37,5 @@
end

if ENV['S3_ACCESS_KEY_ID']
S3_CONFIG = { 'access_key_id' => ENV['S3_ACCESS_KEY_ID'], 'secret_access_key' => ENV['S3_SECRET_ACCESS_KEY'] }
S3_CONFIG = { 'access_key_id' => ENV['S3_ACCESS_KEY_ID'], 'secret_access_key' => ENV['S3_SECRET_ACCESS_KEY'], 'bucket' => ENV['S3_BUCKET'] }
end

0 comments on commit ae10c0b

Please sign in to comment.