Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. # Giving the faker gem a shot here
  2. if !User.find_by(email: "example@gmail.com")
  3. User.create!(email: "example@gmail.com",
  4. password: "foobar",
  5. password_confirmation: "foobar")
  6.  
  7. end
  8.  
  9. 10.times do |n|
  10. name = Faker::Internet.free_email
  11. email = "example-#{n+1}@gmail.com"
  12. password = "password"
  13. User.create!(
  14. email: email,
  15. password: password,
  16. password_confirmation: password)
  17.  
  18. end
  19.  
  20. # What is syntax to add in custom terms like "Grass-Fed, pastured, sustainably-raise, organic, etc?"
  21. users = User.order(:created_at).take(6)
  22. 10.times do
  23. message = Faker::Hipster.paragraph
  24. users.each { |user| user.posts.create!(title: title, message: message, organic: yes, price: price, location: location) }
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement