An introduction to Active Record
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Gemfile
Gemfile.lock
README.md
associations.rb

README.md

Healthy Relationships

Skill Level: Intermediate
Time Limit: 30 minutes

Active Record is a object relational mapper that connects classes to relational database tables. These classes are commonly called models. Models can also be connected to other models by defining associations.

Under the surface, Active Record provides a level of abstraction that helps you reduce the amount of SQL you would have to write for simple and sometimes complex statements.

Instructions

Fill out the migrations and models in the associations.rb file in such a way that the resulting methods produce the expected output. I've also included a few helper gems that should help with visualizing these models and their relationships.

Example:

class Person < ActiveRecord::Base  
  has_many :orders  
end

Person.create(name: Jill, age: 45)  
Person.orders << Order.create(description: "Pizza Boxes")  
p Person.orders.first => #<Order: id: 1, description: '...'>

Resources

Table Print Gem
Awesome Print Gem
Active Record Basics Association Basics