I am new to Ruby and I am pretty sure it’s a “meta-programming” feature of Ruby. How does the ActiveRecord::Base dynamically generate instance vars? actually, how does any ruby class generate instance vars at runtime?
Sorry if this is a noob question, i just got started with ruby.
Active Record objects don‘t specify their attributes and variables directly, but infer them from the table definition with which they‘re linked in the database.
Adding, removing, and changing attributes and their type is carried out directly in the database.
Any change is instantly reflected in the Active Record objects. The mapping that binds a given Active Record class to a certain database table will happen automatically in most common cases, but can be overwritten for the uncommon ones.
Learn more of Active Record here