Here is a quick reference on how to insert, retrieve, update, and delete rows from your database tables using our ActiveRecord-backed Ruby classes.
First, we need a Ruby class to represent the real-world thing we're trying to model, and we need an underlying database table to store information about each individual thing.
Rails includes an easy generator to help us get set up with both of these things quickly. Supposed I wanted to create a table to store instructors, with two string columns first_name
and last_name
. I could use this shortcut from the Command Line: