Skip to content

Instantly share code, notes, and snippets.

@tra38
Created December 2, 2015 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tra38/62787708770b8e691d0c to your computer and use it in GitHub Desktop.
Save tra38/62787708770b8e691d0c to your computer and use it in GitHub Desktop.
require 'open-uri'
@book_array = ['A Year of Walking', 'Candy For Two', 'Walking and Running', 'The Frog Catchers Field Manual', 'Tomato in the Window', 'A Dozen Heros', 'Finding a New Sun', 'Stop Asking, Just Do', 'What Lives on Pluto', 'Fishing With Chips', 'No Lonely Stars', 'Free Parking', 'Next Day Previous Night', 'Burning Water', 'Slicker Than Rain', 'Future Discretions', 'Covered and Warm', 'The Odd Sister', 'Falling Flags', 'Keyboard For Hire', 'Ready, Set, Die', 'Same Way Through', 'The Zookeeper and Her Tiger']
def placeholder(slug)
slug = slug.gsub(/\s/,"+")
open "https://placeholdit.imgix.net/~text?txtsize=25&txt=#{slug}&w=700&h=400&txttrack=0"
end
18.times do
User.create!(username: "#{Faker::Internet.user_name}", password: "password", password_confirmation: "password", email: "#{Faker::Internet.safe_email}")
end
40.times do
slug = @book_array.sample
Offer.create(user: @users.sample, book_title: slug, picture: placeholder(slug), price: Faker::Number.between(20,140), university: Faker::University.name, course: Faker::Commerce.department(2), status: "ACTIVE")
end
##Result is that I uploaded a blank image to the database
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment