Skip to content

Example repo for uploading files to S3 with PaperClip and Rails 4.1

Notifications You must be signed in to change notification settings

uploaders/paperclip-s3-rails-4.1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PaperClip - Example

By:

Forrest Parker

Phillip Nguyen

Gems: gem 'paperclip' gem 'aws-sdk'

Step by Step guide!

  • $ rails new pclip-example

  • Add gems to gem file

  • $ bundle

  • $ rails g scaffold article title:string body:text

  • In config/routes.rb set your 'root articles#home'

  • $ rails g migrations addattachmentimagetoarticles this should generate a file kind of like this.

      def change
        add_attachment :users, :avatar
      end
    end```
    
    
  • In app/views/articles/_form.html.erb add this line somewhere <%= f.file_field :image %>

  • In app/views/articles/show.html.erb add this line somewhere <%= f.file_field :image %>

  • In config/environments/development.rb add this to set up aws keys and stuff (notice the url listed in the bucket, you will likely change it to your bucket name with the region you are set up in.) ALSO! DO NOT HARDCODE YOUR KEYS HERE!

      :storage => :s3,
      :s3_credentials => {
        :bucket => 'cw-example.s3-website-us-west-2.amazonaws.com',
        :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
        :secret_access_key => ENV['AWS_SECRET_KEY']
      }
    }```
    
    

Happy Coding and Thanks!

About

Example repo for uploading files to S3 with PaperClip and Rails 4.1

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published