Skip to content

Commit

Permalink
Create image populate for S3
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Gehani committed Nov 13, 2013
1 parent 064a09c commit a77b8e2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gem 'jquery-rails'
gem 'devise', '~> 3.1.1'
gem 'simple_form', '~> 3.0.0.rc'
gem "paperclip", "~> 3.0"
gem 'aws-sdk', '~> 1.20.0'
gem 'aws-sdk', '~> 1.5.7'
gem "masonry-rails", '~> 0.2.0'
gem 'faker'
gem 'will_paginate', '3.0.3'
Expand Down
15 changes: 11 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ GEM
acts_as_follower (0.2.0)
arel (4.0.0)
atomic (1.1.14)
aws-sdk (1.20.0)
aws-sdk (1.5.8)
httparty (~> 0.7)
json (~> 1.4)
nokogiri (>= 1.4.4, < 1.6.0)
nokogiri (>= 1.4.4)
uuidtools (~> 2.1)
bcrypt-ruby (3.1.2)
bootstrap-will_paginate (0.0.10)
Expand Down Expand Up @@ -66,6 +67,9 @@ GEM
faker (1.2.0)
i18n (~> 0.5)
hike (1.2.3)
httparty (0.12.0)
json (~> 1.8)
multi_xml (>= 0.5.2)
i18n (0.6.5)
jbuilder (1.2.0)
activesupport (>= 3.0.0)
Expand All @@ -82,9 +86,12 @@ GEM
masonry-rails (0.2.0)
rails
mime-types (1.25)
mini_portile (0.5.2)
minitest (4.7.5)
multi_json (1.8.0)
nokogiri (1.5.10)
multi_xml (0.5.5)
nokogiri (1.6.0)
mini_portile (~> 0.5.0)
orm_adapter (0.4.0)
paperclip (3.5.1)
activemodel (>= 3.0.0)
Expand Down Expand Up @@ -163,7 +170,7 @@ PLATFORMS

DEPENDENCIES
acts_as_follower
aws-sdk (~> 1.20.0)
aws-sdk (~> 1.5.7)
bootstrap-sass!
bootstrap-will_paginate
coffee-rails (~> 4.0.0)
Expand Down
3 changes: 1 addition & 2 deletions config/initializers/paperclip.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# config/initializers/paperclip.rb
Paperclip::Attachment.default_options[:s3_host_name] = 'event_sample_images.s3.amazonaws.com'
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename'
Paperclip::Attachment.default_options[:s3_host_name] = 'event_sample_images.s3-website-us-east-1.amazonaws.com'
15 changes: 15 additions & 0 deletions lib/tasks/populateimages3
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'open-uri'
namespace :db do
desc "Fill database with sample data"
task populateimage: :environment do

User.all.each do |user|
puts "[DEBUG] uploading images for user #{user.id} of #{User.last.id}"
10.times do |n|
image = open('http://s3.amazonaws.com/event_sample_images').sample
description = %w(cool awesome crazy wow adorbs incredible).sample
user.pins.create!(image: image, description: description)
end
end
end
end

0 comments on commit a77b8e2

Please sign in to comment.