I am started to learn Ruby and Rails, sometime the "Convention over configuration" kind of killing me...
OK, I created a
class User < ApplicationRecord
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
ActiveRecord doesn't modify your code, it doesn't alter how things are implemented. What it does instead, which is a common pattern in Ruby, is define methods dynamically. This is often referred to as "meta-programming" since your code effectively writes code. Note that it doesn't literally write code, it's only when the program's loaded in memory that it transforms itself.
The columns are usually automatically discovered by running a SQL command like
SHOW FIELDS to determine the structure and types. Then these methods get generated accordingly.
If you want to know the mechanism you can always read the ActiveRecord source code, though keep in mind it does a lot of things and may be a little difficult to navigate at times.