From the course: Ruby on Rails 6 Essential Training

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Using the Rails console to interact with a Rails project

Using the Rails console to interact with a Rails project - Ruby on Rails Tutorial

From the course: Ruby on Rails 6 Essential Training

Start my 1-month free trial

Using the Rails console to interact with a Rails project

- [Instructor] The Rails Console is a useful tool. It's especially helpful because it allows us to experiment with a project's models in isolation. We're going to use it to explore the models without having to worry about the controllers or views. The way that you launch the Rails Console is you go to the command line and navigate to the root of your Rails project and then enter the command rails console and then if you want to specify the environment, you'd use -e and the environment. So for example, -e development, -e production, or -e test. Most of the time, we're going to be using it in development so we can just leave the -e option off and development will be chosen by default. If we're on production though, you will need to specify that. You can also shorten it to just rails c. In the same way that we do rails s to launch the server, rails c will launch the console. So from the command line in the root of my…

Contents