Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exercise in RoR book by M. Hartl

I've been following the exercises in the Ruby-on-Rails tutorial by M. Hartl. I have completed all the exercises in chapter 4 but am stuck on this one:

Create three hashes called person1, person2, and person3, with first and last names under the keys :first and :last. Then create a params hash so that params[:father] is person1, params[:mother] is person2, and params[:child] is person3. Verify that, for example, params[:father][:first] has the right value.

Can anyone suggest how to approach this problem? I don't want to proceed to next chapter until I have solved this.

like image 429
Avdept Avatar asked Nov 29 '22 09:11

Avdept


1 Answers

person1 = {:first => 'Al',    :last => 'Bundy'}
person2 = {:first => 'Peggy', :last => 'Bundy'}
person3 = {:first => 'Kelly', :last => 'Bundy'}
params = {
 :father => person1,
 :mother => person2,
 :child  => person3
}
params[:father][:first] #=> 'Al'
like image 197
Unixmonkey Avatar answered Dec 01 '22 00:12

Unixmonkey