Intern Track Roadmap

Rails console (IRB)

This course covers the Rails console, started with bin/rails console or bin/rails c. The console is IRB, Ruby's interactive shell, with every class of the app already loaded. No server, browser or HTTP request is involved. The lessons build a model instance and call its methods, then use the app and helper objects to visit routes and call view helpers. They also cover reload! for edited code, inspect mode, the underscore variable, and sandbox mode, which rolls back every write on exit.

What you'll learn

  • ✓Starting and leaving the console with bin/rails console, bin/rails c, exit and Ctrl+D
  • ✓Running plain Ruby and the app's classes at the prompt without require
  • ✓Building model instances and calling their methods without a browser
  • ✓Visiting routes with app and calling view helpers with helper
  • ✓Reloading code with reload!, reading inspect mode output and reusing results with _
  • ✓Experimenting with --sandbox, where writes roll back on exit
Free preview · Lesson 1 2 min read

Starting the Rails console

So far this arc has been about bin/rails server, Puma and a browser sending HTTP requests. There's another way to run Rails code that skips the browser, the server and HTTP: the Rails console.

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...