GithubHelp home page GithubHelp logo

majormatt28 / active-record-crud-practice Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sylwiavargas/active-record-crud-practice

0.0 0.0 0.0 18 KB

๐ŸŒฑ learn ActiveRecord through practicing on plants and their parents ๐ŸŒฑ

Ruby 100.00%

active-record-crud-practice's Introduction

ActiveRecord CRUD

SWBATs

  • Get comfortable with checking rake -T
  • Practice setting up a table and a model
  • Practice CRUD in ActiveRecord
  • Understand the use case for global variables in Ruby
  • Use the colorize gem to make the console outputs pretty

Outline

Welcome to the ActiveRecord obstacle run! Before you begin:

  1. run bundle
  2. run rake db:migrate
  3. check the schema.rb to see what you have there -- are there any new datatypes?
  4. open db/seeds.rb and read it through
  5. run rake db:seed
  6. open rake console and see what plants have been created (check how the date was handled)
  7. run rake -T and read the tasks marked as "๐ŸŽ" and their descriptions

After the last command, you will notice a remind_me_about: rake tasks (the ones marked with the ๐ŸŽ). This is a carefully created set of process reminders for the key deliverables for this review and onwards. Even if you feel confident with AR, please check the instructions every time.

You will be working in groups. Good news is that if your database setup looks the same, you can just send schema.rb and development.sqlite files after each person drives to hand over the database to the next person.

Hint: For this lab, it is best that you have two terminals open: one in your VS Code and another on a split screen. Run the remind_me_about commands on the split screen and follow them in the VS Code.

Roadmap

The goal of this obstacle course is for you to practice CRUD and to end with two models (and tables) in your project: Plant and Person. You have been already given a ready Plant class and corresponding table. In the database, there are already a few instances of Plant class.

  1. Run rake remind_me_about:adding_table and follow the instructions to create a Person table with name attribute (string)
  2. Run rake remind_me_about:adding_column and follow the instructions to add likes_plants? attribute (boolean) NOTE: Hopefully, this will result in an error please read it and debug it together (it's a gotcha and that's fine!)
  3. Run rake remind_me_about:adding_column let's add another column -> eye_color (string) to the Person table
  4. Run rake remind_me_about:rolling_back and follow the instructions to roll back just last migration because YAGNI
  5. Run rake remind_me_about:adding_column and follow the instructions to add free_time attribute (string), which will tell us when the person is free to water the plants and another column, age (integer).
    hint you can do that in one file because you're changing just one table!

HEADS UP: for all the next steps you can stay in the same rake console session!

  1. Run rake remind_me_about:creating_an_instance and follow the instructions to create at least 3 instances of Person class and save them to the database
  2. Run rake remind_me_about:reading_instances and follow the instructions to read more about each Person
  3. Oho! One of the folks just had birthday! Run rake remind_me_about:updating_an_instance and follow the instructions to change their age
  4. In the quarantine time, everyone is free to water the plants all day. Run rake remind_me_about:updating_all_instances and follow the instructions to change everyone's free time
  5. Oops, it turns out you need to water cacti 0.0 Find a plant with the "cactus" name and delete it from the database. Run rake remind_me_about:deleting_an_instance and follow the instructions.
  6. If everyone is watering the plants, it's a recipe for a disaster. All plants died. Run rake remind_me_about:deleting_all_instances and follow the instructions to bid the last goodbye to all the green friends.

active-record-crud-practice's People

Contributors

sylwiavargas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.