Query methods allow for constructing queries that locate records based on complex criteria. Conditions can be chained together and can be expressed as a string, an array, or a hash. To prevent SQL injection, it is important to understand the differences between them so you pick the right one.
- [Instructor] We've seen how to perform…the basic find operations, but most times,…on their own, these are too simple to search…for records that match complex criteria.…Instead, we'll need to construct queries.…Let's start that by looking at conditions.…Conditions let you specify the criteria…that the data must meet to be part of the query results.…So we use the method where, and then tell it…what conditions it ought to meet.…So for example, Subject.where and then…I'm providing the hash with (:visible => true).…
This is going to look for subjects…where the visible column or attribute is equal to true.…We can express this condition in several different ways.…We can use a string, we can use an array,…or we can use a hash.…Let's look at each one.…With a string, you can just simply provide a string…that gets dropped into that where statement.…This would find all subjects where the name was Test…and visible was equal to true.…This is flexible because we get to issue raw SQL in here,…and it will drop it straight into our query.…
- 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?
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.