Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails for Zombies Lab 4 > Exercise 3


I stucked in the fourth Rails for Zombies lab at the third exercise. This is my task: Create action that will create a new Zombie and then redirect to the created zombie's show page. I've got the following params array:

params = { :zombie => { :name => "Greg", :graveyard => "TBA" } }

I wrote the following code as a solution:

def create
   @zombie = Zombie.create   
   @zombie.name = params[ :zombie [ :name ] ]   
   @zombie.graveyard = params[ :zombie [ :graveyard ] ]
   @zombie.save   

   redirect_to(create_zombie_path)
end

But when I submit it I got the following error:
#<TypeError: can't convert Symbol into Integer>

I know that I made a mistake but I cannot figure out where. Please help me.

like image 509
nosferat Avatar asked Mar 07 '11 12:03

nosferat


1 Answers

def create
   @zombie = Zombie.create(params[:zombie])
   redirect_to @zombie
end
like image 103
YOU Avatar answered Oct 23 '22 09:10

YOU