Skip to content

Home (Eagle Only)#3

Closed
johnnygoodman wants to merge 1 commit intoRubyoffRails:masterfrom
johnnygoodman:master
Closed

Home (Eagle Only)#3
johnnygoodman wants to merge 1 commit intoRubyoffRails:masterfrom
johnnygoodman:master

Conversation

@johnnygoodman
Copy link

I cloned down the pre-Panda/Tiger/Eagle homework and had a chance to work on it today during a plane ride.

I will go back and push the Panda and Tiger, but please have a look at this.

Also, a question I ran into while working this:

Garden.all.each do |garden|  
  garden.class #=> Garden
end

but..

garden = Garden.where(category: "Berries")
garden.class #=> ActiveRecord::Relation

Why so? I wanted to query via where and then use the result to do a garden.plants thing, but no dice...

@jwo
Copy link
Member

jwo commented May 8, 2012

garden = Garden.where(category: "Berries")

That's because this is still a query at this point.... For example, if I want to find the record for ME, I might have to:

User.where(github: "jwo").first

the #first is important, it executes the query and returns the first record. Try yours with:

garden = Garden.where(category: "Berries").first
garden.class
  #=> Garden

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to refrain from using "p" or "x" as variable names in ruby -- "plant_names" would be easier to read in a couple of months.

@jwo jwo closed this Aug 11, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants