There are several ways to find records in the database. Records can be retrieved by their primary key, by an attribute, all at once, or just the first/last record.
- [Narrator] In your application, you're going to find…that you're querying for existing records…far more often than you're creating,…updating, or deleting them.…Active Record offers us many tools to make…finding the right records easier.…Over the course of the next few movies,…we're going to learn how to construct queries in rails.…We're going to begin with the simplest of these.…The first is the primary key finder,…and it's the one we saw already.…We have the class name then a dot and then find…and find is going to expect the primary key…that we want to user to find the record.…
So, in this case, it would find a subject…who's primary key, on ID, is two.…The result will either be an object,…if it finds one, or it will raise an error…if the object does not exist.…You want to use this when it would actually be surprising…to you, if the object isn't in the database.…The second possibility is to use dynamic finders.…Dynamic finders allow you to be able to…find records by different attributes.…They always start with find_by_ and then…
- 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.