Giter VIP home page Giter VIP logo

active-record-discussion-questions's Introduction

ActiveRecord Discussion Questions

Part One - Reading the Documentation

Looking at Documentation is an important part of programming. You don't have to memorize anything, but you should get familiar with the types of information you can find in different docs. For this exercise, go through the ActiveRecord documentation here with your table mates and answer the following questions about each method.

  1. What argument or arguments does the method take?
  2. What type of object does the method return?
  3. What happens if none of the parameters match? (i.e. what if Tweet.find(5) can't find that tweet? How about Tweet.find_by(id: 6)?

Methods:

  1. find
  2. .find_by
  3. .where
  4. .all
  5. .first
  6. .destroy

Part Two - Name that SQL!

Pretend that you have a tweets table with two columns - message and user_id. Given the code below, write in a notebook or on a whiteboard what SQL statements will fire when the following methods are called?

class Tweet < ActiveRecord::Base

end
  1. Tweet.all
  2. Tweet.find(5)
  3. Tweet.find_by(user_id: 7)
  4. Tweet.where(user_id: 7)
  5. Tweet.create(user_id: 5, message: 'making some coffee')
  6. Tweet.destroy(7)

active-record-discussion-questions's People

Contributors

ipc103 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.