Exercise in the book RoR M. Hartle

I did the exercises in M. Hartle 's Ruby-on-Rails tutorial . I did all the exercises in chapter 4, but was stuck with this:

Create three hashes called person1, person2and person3, with first and last names under the :firstand keys :last. Then, create a hash paramsthat params[:father]has been person1, params[:mother]is person2, and params[:child]- person3. Make sure that, for example, params[:father][:first]has the correct value.

Can anyone suggest how to approach this problem? I do not want to go to the next chapter until I solve this.

+3
source share
2 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'
+19
source

Hash. , , javascript:

person1 = {first: "Papa", last: "Bear"}
person2 = {first: "Mama", last: "Bear"}
person3 = {first: "Baby", last: "Bear"}
params = {father: person1, mother: person2, child: person3}
+5

All Articles