From the course: Ruby on Rails 6 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Using the Rails console to interact with a Rails project - Ruby on Rails Tutorial
From the course: Ruby on Rails 6 Essential Training
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Understanding ActiveRecord and ActiveRelation4m 32s
-
(Locked)
Using the Rails console to interact with a Rails project3m 36s
-
Create records using ActiveRecord5m 11s
-
(Locked)
Update records using ActiveRecord3m 53s
-
(Locked)
Delete records using ActiveRecord3m 18s
-
(Locked)
Find records using ActiveRecord6m 33s
-
(Locked)
Define one-to-many associations between models6m 30s
-
(Locked)
-
-
-