Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby ActiveRecord Basics Query Interface Finding Scopes 2

Ace Motanya
Ace Motanya
31,756 Points

Build a finder scope called hamptons to find all people with the first_name "Hampton"

I do not think I am querying against the current Person or something but I have tried everything and nothing will work. I have tried using self.first_name and @first_name.

4 Answers

Ace Motanya
Ace Motanya
31,756 Points

class Person < ActiveRecord::Base

scope :hamptons, -> { where(first_name: "Hampton")}

end

Ace Motanya
Ace Motanya
31,756 Points

Oh, nevermind. I got it working, with first_name: "Hampton"

I had an extra comma between it.

Sorry I am having the same problem what is the full answer?

Here's the answer:

scope :hamptons, -> { where(first_name: "Hampton")}

How is "scope :hamptons, -> { where("first_name = ?", "Hampton") }" not an acceptable answer... ?