Learn how to access models through the Rails console, in order to create new records in the database. There are two approaches to saving records: new/save and create.
- [Kevin] In this movie, we'll use the Rails console…to access our models and to create new records…in the database.…I'm going to show you two different techniques…to accomplish this.…The first I refer to as new/save.…It's a three-step process.…First, we instantiate an object.…Instantiate means to create a new object of the class.…This object is also called an instance of the class.…And then we can set values on that instance.…And then when we have all the values set,…we save the object to the database.…
It's a three-step process:…create a new object, set its values, and then save it.…The second technique is to do it…all in one step using Create.…That is that we instantiate an object,…set its values, and save it all in one step.…Let's try both out starting with the new/save technique.…From the root of your Rails project,…you'll enter the Rails console with rails console.…And then let's access our subject using subject =…Subject, capital, .new.…
This is gonna create a new instance of my subject class.…Now, Active Record has a number of methods built-in to it…
- Creating and configuring a new Ruby on Rails project
- Generating controllers and views
- Handling server requests
- Using different types of routes
- Rendering and viewing templates
- Generating migrations and models
- Creating, updating, and deleting records
- Finding records with queries
- Understanding relationship types
- Writing controllers for CRUD
- Working with layouts and helpers
- Managing application assets
- Building forms
- Validating data
- Authenticating users
Skill Level Beginner
1. What Is Ruby on Rails?
2. Get Started
3. Controllers, Views, and Dynamic Content
4. Databases and Migrations
5. Models and ActiveRecord
7. CRUD, REST, and Resourceful Routes
8. Controllers and CRUD
9. Layouts, Partials, and View Helpers
12. Data Validation
13. Controller Features
14. User Authentication
15. Improve the Simple CMS
Next steps1m 44s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.