1 00:00:00,000 --> 00:00:04,750 [MUSIC] 2 00:00:04,750 --> 00:00:08,608 We've seen how to use the web interface to create new model objects. 3 00:00:08,608 --> 00:00:12,850 Now I wanna show you how to do the same from the terminal using the Rails console. 4 00:00:12,850 --> 00:00:16,800 The Rails console is useful when you need to do an operation on many model objects 5 00:00:16,800 --> 00:00:20,520 at once, or to look at model attributes that you haven't yet added to your views. 6 00:00:21,810 --> 00:00:25,490 We've seen the Rails server and generate sub commands already. 7 00:00:25,490 --> 00:00:27,730 Console is another sub command. 8 00:00:27,730 --> 00:00:29,830 So let's make sure the Rails server is stopped and 9 00:00:29,830 --> 00:00:31,700 we're back at our system prompt. 10 00:00:31,700 --> 00:00:35,670 Then we type bin/ rails console in our terminal. 11 00:00:37,100 --> 00:00:40,770 You'll leave your system prompt and be taken to a prompt provided by Ruby. 12 00:00:40,770 --> 00:00:42,870 Here you can type Ruby expressions. 13 00:00:42,870 --> 00:00:45,520 They'll be evaluated and you'll be shown the result. 14 00:00:45,520 --> 00:00:49,560 If you've used Ruby's IRB command before, it works just the same way. 15 00:00:49,560 --> 00:00:52,370 The difference is you have your full Rails environment loaded, 16 00:00:52,370 --> 00:00:54,410 including your model classes. 17 00:00:54,410 --> 00:00:56,720 Your model class is connected to your database so 18 00:00:56,720 --> 00:01:00,450 you can create, read, update, or delete model data. 19 00:01:00,450 --> 00:01:03,880 Let's try out all the cred operations using our post model class.