nosferat nosferat - 1 year ago 85
Ruby Question

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 = params[ :zombie [ :name ] ]
@zombie.graveyard = params[ :zombie [ :graveyard ] ]


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.

Answer Source
def create
   @zombie = Zombie.create(params[:zombie])
   redirect_to @zombie