Last active
December 28, 2015 05:39
-
-
Save ml242/7451696 to your computer and use it in GitHub Desktop.
Amazon AWS install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew install imagemagick | |
gem install paperclip | |
-> add paperclip to gem file | |
gem install aws-sdk | |
gem 'paperclip' | |
gem 'aws-sdk' | |
rails new project | |
rails generate paperclip User image | |
rake db:migrate | |
<div class="field"> | |
<%= f.file_field :image %> | |
</div> | |
User Model | |
-> attr accessible :name, :image | |
has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png" | |
end | |
show user page | |
<p> | |
<b>Name:</b> | |
<%= @user.name %> | |
<%= image_tag(@user.image.url(:thumb)) %> | |
</p> | |
change production.rb environmental variables. | |
config.paperclip_defaults = { | |
:storage => :s3, | |
:s3_credentials => { | |
:bucket => ENV['S3_BUCKET_NAME'], | |
:access_key_id => ENV['AWS_ACCESS_KEY_ID'], | |
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'] | |
} | |
.extra file needs to include secret keys | |
inside config initializers create paperclip.rb | |
Paperclip::Attachment.default_options[:url] = ':s3_domain_url' | |
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment