Giter Club home page Giter Club logo

activerecord-crud-online-web-pt-120919's Introduction

Active Record CRUD

Objective

The goal of this lab is to get comfortable performing CRUD (Create, Read, Update, Delete) actions using Active Record.

There are different ways to solve this lab so feel free to experiment!

Instructions

Before starting this lab run bundle, to get the proper gem dependencies. If your operating system is OSX El Capitan, and you have an issue installing EventMachine, first check to make sure Open SSL is installed by entering brew install openssl in terminal. Once it's installed, enter brew link openssl --force.

Also enter rake -T, which will list all of the rake tasks you have available in this lab. These tasks come with the sinatra-activerecord gem.

Start the lab by running learn or keep reading for more instructions.

Create Table

Try using the rake task rake db:create_migration NAME=create_movies to create your migration file. Once you have a migration file add columns like so:

Column Name Type
title (string)
release_date (integer)
director (string)
lead (string)
in_theaters (boolean)

After your migration is ready run rake db:migrate to migrate your table and rake db:migrate SINATRA_ENV=test to migrate a test database so you will be able to run learn

Tests

Run rspec or learn to see the tests. To make them pass open movie_controller.rb and complete each method. It will help to open spec/models/movie_spec.rb to see exactly what each spec is testing for.

In each method the __ corresponds to a line of code you will need to write to make the spec pass.

Each test will take us through performing a basic CRUD action using the database we just created. These tests will take you through:

Create

  • A movie can be instantiated, given a title, and saved
  • A movie can be instantiated with a hash containing all of its attributes
  • A movie can be created in a block

Read

  • You can return the first item in the table
  • You can return the last item in the table
  • You can return the number of records in the table
  • You can return a movie from the table based on its attributes
  • You can use a where clause to select the appropriate movies and sort them by release date

Update

  • Can be found, updated, and saved
  • Can be updated using the update method
  • Can update all records at once

Destroy

  • Can destroy a single item
  • Can destroy all items at once

Resources

Active Record Query Interface.

View Active Record CRUD on Learn.co and start learning to code for free.

activerecord-crud-online-web-pt-120919's People

Contributors

ahimmelstoss avatar annjohn avatar aspenjames avatar aviflombaum avatar azemoh avatar benjagross avatar bhollan avatar curiositypaths avatar deniznida avatar dependabot[bot] avatar echospr avatar fislabstest avatar fs-lms-test-bot avatar gj avatar irmiller22 avatar johann avatar joshua-miles avatar maxwellbenton avatar pletcher avatar rrcobb avatar sarogers avatar schuylermaclay avatar sgharms avatar victhevenot avatar

Watchers

 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.