seeds.rb 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #---
  2. # Excerpted from "Agile Web Development with Rails 8",
  3. # published by The Pragmatic Bookshelf.
  4. # Copyrights apply to this code. It may not be used to create training material,
  5. # courses, books, articles, and the like. Contact us if you are in doubt.
  6. # We make no guarantees that this code is fit for any purpose.
  7. # Visit https://pragprog.com/titles/rails8 for more book information.
  8. #---
  9. # encoding: utf-8
  10. Product.delete_all
  11. product = Product.create(title: 'Programming Ruby 3.3 (5th Edition)',
  12. description:
  13. %(<p>
  14. <em>The Pragmatic Programmers' Guide</em>
  15. Ruby is one of the most important programming languages in use for web
  16. development. It powers the Rails framework, which is the backing of some
  17. of the most important sites on the web. The Pickaxe Book, named for the
  18. tool on the cover, is the definitive reference on Ruby, a
  19. highly-regarded, fully object-oriented programming language. This updated
  20. edition is a comprehensive reference on the language itself, with a
  21. tutorial on the most important features of Ruby—including pattern
  22. matching and Ractors—and describes the language through Ruby 3.3.
  23. </p>),
  24. price: 33.95)
  25. product.image.attach(io: File.open(
  26. Rails.root.join('db', 'images', 'ruby5.jpg')),
  27. filename: 'ruby5.jpg')
  28. product.save!
  29. # . . .
  30. product = Product.create(title: 'Rails Scales!',
  31. description:
  32. %(<p>
  33. <em>Practical Techniques for Performance and Growth</em>
  34. Rails doesn’t scale. So say the naysayers. They’re wrong. Ruby on Rails
  35. runs some of the biggest sites in the world, impacting the lives of
  36. millions of users while efficiently crunching petabytes of data. This
  37. book reveals how they do it, and how you can apply the same techniques
  38. to your applications. Optimize everything necessary to make an
  39. application function at scale: monitoring, product design, Ruby code,
  40. software architecture, database access, caching, and more. Even if your
  41. app may never have millions of users, you reduce the costs of hosting
  42. and maintaining it.
  43. </p>),
  44. price: 30.95)
  45. product.image.attach(io: File.open(
  46. Rails.root.join('db', 'images', 'cprpo.jpg')),
  47. filename: 'cprpo.jpg')
  48. product.save!
  49. # . . .
  50. product = Product.create(title: 'Modern Front-End Development for Rails, Second Edition',
  51. description:
  52. %(<p>
  53. <em>Hotwire, Stimulus, Turbo, and React</em>
  54. Improve the user experience for your Rails app with rich, engaging
  55. client-side interactions. Learn to use the Rails 7 tools and simplify the
  56. complex JavaScript ecosystem. It’s easier than ever to build user
  57. interactions with Hotwire, Turbo, and Stimulus. You can add great
  58. front-end flair without much extra complication. Use React to build a
  59. more complex set of client-side features. Structure your code for
  60. different levels of client-side needs with these powerful options. Add to
  61. your toolkit today!
  62. </p>),
  63. price: 28.95)
  64. product.image.attach(io: File.open(
  65. Rails.root.join('db', 'images', 'nrclient2.jpg')),
  66. filename: 'nrclient2.jpg')
  67. product.save!