From the course: Ruby on Rails 6 Essential Training: Models and Associations

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Challenge: Named scopes

Challenge: Named scopes - Ruby on Rails Tutorial

From the course: Ruby on Rails 6 Essential Training: Models and Associations

Start my 1-month free trial

Challenge: Named scopes

(upbeat music) - [Instructor] Time for a challenge assignment. For this challenge, we're going to use what you've learned in this chapter, and especially what we learned about named scopes. Your challenge is to add scopes for visible and invisible to the page model. You also should add a scope for sorted to the subject, page, and user model. And it's up to you how you sort those. You're setting, essentially, what's a convenient sort whenever you call sorted. And then I want you to try adding a scope to search subjects.name for a keyword. I gave you an example of that in the last movie, you can refer back to that if you need help. And once you've written your scopes, go into the rails console and try them all out. In the next movie, I'll show you the solution that I came up with.

Contents