[{"data":1,"prerenderedAt":139},["ShallowReactive",2],{"term-a\u002Factive-record":3,"related-a\u002Factive-record":122},{"id":4,"title":5,"acronym":6,"body":7,"category":104,"description":105,"difficulty":106,"extension":107,"letter":108,"meta":109,"navigation":79,"path":110,"related":111,"seo":116,"sitemap":117,"stem":120,"subcategory":6,"__hash__":121},"terms\u002Fterms\u002Fa\u002Factive-record.md","Active Record",null,{"type":8,"value":9,"toc":98},"minimark",[10,15,28,32,35,39,87,91,94],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 — The Vibe Check",[16,17,18,19,23,24,27],"p",{},"Active Record is an ORM pattern where each database row becomes an object that knows how to save itself. The User object doesn't just hold data — it can also call ",[20,21,22],"code",{},"user.save()"," or ",[20,25,26],{},"user.delete()"," directly. The data and the database logic live in the same object.",[11,29,31],{"id":30},"real-talk","Real Talk",[16,33,34],{},"Active Record is an ORM pattern where models directly correspond to database tables and instances represent rows. The model contains both data and database access methods. It's the foundational pattern in Rails and is used in many other frameworks.",[11,36,38],{"id":37},"show-me-the-code","Show Me The Code",[40,41,46],"pre",{"className":42,"code":43,"language":44,"meta":45,"style":45},"language-ruby shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F\u002F Rails Active Record\nuser = User.find(1)\nuser.name = 'Alice'\nuser.save\n\nUser.where(active: true).order(:created_at)\n","ruby","",[20,47,48,56,62,68,74,81],{"__ignoreMap":45},[49,50,53],"span",{"class":51,"line":52},"line",1,[49,54,55],{},"\u002F\u002F Rails Active Record\n",[49,57,59],{"class":51,"line":58},2,[49,60,61],{},"user = User.find(1)\n",[49,63,65],{"class":51,"line":64},3,[49,66,67],{},"user.name = 'Alice'\n",[49,69,71],{"class":51,"line":70},4,[49,72,73],{},"user.save\n",[49,75,77],{"class":51,"line":76},5,[49,78,80],{"emptyLinePlaceholder":79},true,"\n",[49,82,84],{"class":51,"line":83},6,[49,85,86],{},"User.where(active: true).order(:created_at)\n",[11,88,90],{"id":89},"when-youll-hear-this","When You'll Hear This",[16,92,93],{},"\"Rails uses Active Record for all database operations.\" \u002F \"Just call .save() on the model instance.\"",[95,96,97],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":45,"searchDepth":58,"depth":58,"links":99},[100,101,102,103],{"id":13,"depth":58,"text":14},{"id":30,"depth":58,"text":31},{"id":37,"depth":58,"text":38},{"id":89,"depth":58,"text":90},"backend","Active Record is an ORM pattern where each database row becomes an object that knows how to save itself.","intermediate","md","a",{},"\u002Fterms\u002Fa\u002Factive-record",[112,113,114,115],"ORM","Model","Query Builder","Migration",{"title":5,"description":105},{"changefreq":118,"priority":119},"weekly",0.7,"terms\u002Fa\u002Factive-record","ZHFByF_XazmfJ4YhpSyVitCptHFK29RGgDn6aco7iRk",[123,128,132,136],{"title":115,"path":124,"acronym":6,"category":125,"difficulty":126,"description":127},"\u002Fterms\u002Fm\u002Fmigration","database","beginner","A migration is a versioned script that modifies your database schema — adding a column, creating a table, changing a type.",{"title":113,"path":129,"acronym":6,"category":130,"difficulty":126,"description":131},"\u002Fterms\u002Fm\u002Fmodel","ai","A model is the trained AI — the finished product.",{"title":112,"path":133,"acronym":134,"category":104,"difficulty":106,"description":135},"\u002Fterms\u002Fo\u002Form","Object-Relational Mapper","An ORM is like a translator between your code and your database. Instead of writing scary SQL, you just write normal code like `User.",{"title":114,"path":137,"acronym":6,"category":104,"difficulty":106,"description":138},"\u002Fterms\u002Fq\u002Fquery-builder","A query builder lets you build database queries by chaining methods instead of writing raw SQL. It's like assembling a sentence with Lego blocks — `.",1776518254134]