The Brand New Box Rails Book

Getting started with Rails for the benefit of everyone

View the Project on GitHub brandnewbox/bnb-on-rails-book

Rails Console

Now that you have scaffolded a resource let’s talk about ways in which you can access your application outside of a browser. Rails provides a command line interface for you to access various parts of your application.

The Rails console helps with:

The Rails console is accessed inside of your container and can be run with dip rails console (or dip rails c for short).

The Rails console is a full Ruby REPL (e.g. try typing 1 + 1 or Time.now and hitting enter. You’ll get the result!). But it also has access to all of your application code as well. Let’s experiment with some things to show that off.

Rails console experimentation

Further learning

The Rails console isn’t only about accessing your models (though that is a very common use case!). Check out this blog post for some additional tips and capabilities of the console including how to access your route and path helpers, autocompleting, etc.