DEV Community

lughjw
lughjw

Posted on

ActiveRecord: Some Quick Tips

The rules:
Base classes are memory objects
Migration classes are what's stored in the database
They only exist in conjunction because of ActiveRecord magic

A short and sweet background on ActiveRecord concepts. ActiveRecord::Base classes hold the object representation that will be held in memory. ActiveRecord::Migration classes hold how the object is represented in the database. Understanding these things is what finally made me stop wanting to throw my laptop across the room when using ActiveRecord.

Any time you have something that you don't care if it gets lost when you save it, store it in a base file. If you don't want to lose it when it's restored then make sure there's a variable for it in the database.

Top comments (0)