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

Dynamic find

Hey I know this is a bit off the course content but I'm trying to extend and experiment with what I've been taught.

How would I return records that match values stored in a table that belong to a current user and other users?

Say I have a model called profile that has hair_colour, eye_colour, age, gender and other columns how can I find all users with the same age and hair colour as the current logged in user?

I understand I can query like Profile.find(:all, :conditions => [ 'hair_colour => ?', "brown" ]) but how can I query with a value that will be dynamic and belongs to the current_user?

Cheers