The Rails Console
The Rails console helps you to interact with Rails applications using the command line. The Rails console uses IRB and allows you to make use of all Rails methods and interact with data. The Rails console is a very useful tool for experimenting with ideas without actually implementing any code.
Let's try this in our application. From the root of the citireview
application, run the following command:
$rails console
The output should be as follows:
Let's check the Review
model by trying an Active Record query to get all the records from the reviews
table. Type the following command from the Rails console:
Review.all
The Terminal will respond as follows:
We can see clearly that our record, with the correct values for name
and description
, has been created. There are some additional columns in this table as well, which are id
, created_at...