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.
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: '...'>
Table Print Gem
Awesome Print Gem
Active Record Basics
Association Basics