Created
December 2, 2015 04:40
-
-
Save tra38/62787708770b8e691d0c to your computer and use it in GitHub Desktop.
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
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