Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails syntax question

I'm a super newbie in RoR. Right now I'm working on this interesting Rails for Zombies exercises. And I got stuck with some syntax questions...

My code to this is:

Weapon.where(:zombie => "Ash")

But it won't work. If instead I typed:

Weapon.find(1)

I passed (since the first weapon belongs to the zombie Ash anyway).

My question is, what's wrong with my answer with this .where() method?

Thanks in advance.

alt text

alt text

alt text

like image 748
Di Wu Avatar asked Dec 30 '10 07:12

Di Wu


1 Answers

You should have nested the query as follows:

Weapon.where(:zombie => {:name => "Ash"})

That would give you the weapons that belong to the zombies whose names are 'Ash'

like image 153
edgerunner Avatar answered Oct 05 '22 23:10

edgerunner