Learning Ruby On Rails: Day 11

Morgan Fogarty
Oct 29, 2018 · 2 min read
“Black and Blue: The Invisible Man and the Masque of Blackness” Artist: Zak Ové

Today I created a store application called depot:

What happens in the depot?

  • Buyer can browse items, select items to purchase, supply info to make an order.
  • Seller can keep inventory of items to sell, determine orders that are ready to ship and those which have already been shipped.

What do I do to prepare (after writing out user stories)?

  • Draw out user flows.
  • Draw out data diagram.
  • Create the Rails project using the command, rails new depot.
  • Create the database migration, model, controller, views, and helper for products using the command, rails generate scaffold Product title:string description:text image_url:string price:decimal.

Other stuff I learned:

  • A migration represents a change we want to make to the database as a whole, or a change we want to make to the data. These updates can change both the schema and the actual data in the database.
  • A magic command that will undo and redo our last migration is: rails db:migrate:redo.
  • If we change the schema in the code, we run rails db:migrate and rails looks for all the migrations not yet applied and applies them.
  • We want to be able to seed the data so that each programmer doesn’t have to manually enter their own data. Add data to file and then run rails db:seed.

Today I created a Rails project, set up a development database and configured the application to be able to connect to it. I created a products controller and model and set up migrations to create the corresponding products table. Many views have been created as well.

Next step, get product listings tidied up.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store