##Worksheet 1##
Models in greater detail
A model represents an entity which we want to persist. As you can see by opening files under /app/models/
, models are classes which inherit from ActiveRecord::Base
. ActiveRecord gives us vital functionality for communicating with our application's database e.g. for selecting, searching, and saving records. In rails, you can interact with your models (and by proxy, database) using the rails console. To start it, just run rails console
or rails c
for short. It's more or less just like using the ruby interpreter (irb) except you get access to all of your application's classes & modules.
Using rails console try:
- Select a collection of all stations from the database
- Save a new station to the database