Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Vamsi Pavan Mahesh Gunturu
4,541 PointsHow to query the active record for the following scenario
I have a model called StudioOrder where name and price are two attributes. Now I want to get price for a particular name. I am trying to do this .. like StudioOrder.find_by(name: "bla").price .. but it gives me no method error. What is the correct way to do it.
Thanks
1 Answer
Aaron Kaye
10,936 PointsI believe you can do something like this:
StudioOrder.where(:name => "bla").price
Aaron Kaye
10,936 PointsAaron Kaye
10,936 PointsUsing a rails app I have and the rails console, I used a similar syntax as yours (only using my model) so I am thinking it is another issue. Does your schema for StudioOrder have a name field?
Vamsi Pavan Mahesh Gunturu
4,541 PointsVamsi Pavan Mahesh Gunturu
4,541 PointsWhite spacing between brackets and find_by :(