I’m taking an interactive lesson Rails For Zombies
There is a database table called (Zombie) and the following fields
id name graveyard
1 Ash Glen Haven Memorial Cemetary
2 Bob Chapel Hill Cemetary
3 Jim My Fathers Basement
- Is the database table in ruby treated as a Hash?
- How can i find Zombie where id = 1 and store it in a variable?
I finished TryRuby.Org with no problem. I need to understand this concept
I know how to use the language syntax with no problem just need to understand the simple concept.
Your answer is highly appreciated.
Please no comments, I’m seeking an answer.
1) Using ActiveRecord, you’ll get either an activerecord object or an array of active record objects. Each attribute is then accessible as a method :
Zombie.find(1).namefor example2)
zombie = Zombie.find(1)I highly suggest you follow extra tutorials and take a look here : http://guides.rubyonrails.org/active_record_querying.html
Good luck!