AI learning: documentation
This course uses an AI assistant as a tutor for asking why Rails code works, instead of as a code generator. It traces two conventions to the Rails source installed in the project. One is how root_path comes from define_method when the routes are drawn, so link_to can call it. The other is how Article maps to the articles table through undecorated_table_name. It separates asking why about code in hand from pasting unread answers. It also covers phrasing a specific why-question and checking a tutor's explanation against a console check or the gem's source.
What you'll learn
- ✓Why link_to can call root_path, traced to define_method in the Rails source
- ✓How Article maps to the articles table through undecorated_table_name
- ✓The difference between asking why and copying AI code blindly
- ✓How to phrase a specific why-question that asks for the mechanism
- ✓Checking an AI tutor's explanation with a console check or the gem's source
A good question to ask an AI tutor
link_to "Home", root_path and Article.find(1) both work the moment you type them, with no visible explanation of why. One student asks an AI assistant: "write me a method that finds an article by id." Another asks: "I have this Article.find(1) line, and it finds a row in a table called articles…
Read the full lesson free →Curriculum
7 lessonsA good question to ask an AI tutor
Contrasts asking an AI to write code with asking why existing Rails code works, and outlines the course.
Why link_to knows the route
Traces root_path to NamedRouteCollection, which calls define_method for each named route when the routes are drawn.
Why Article maps to articles
Reads undecorated_table_name and follows demodulize, underscore and pluralize as they turn the class name Article into articles.
Asking why vs. copying blindly
Compares asking why .present? works in published? with pasting an AI-written method you have never seen.
How to ask a better why-question
Lists four parts of a specific why-question: the code, the precise behavior, the mechanism, and follow-ups.
Checking what the tutor tells you
Checks a plausible wrong AI explanation of link_to against a console check and the Rails source.
A hundred intern courses, and what's next
Marks the intern level's hundredth course by linking its habit of checking the thing itself to reading AI explanations.