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.
def create
@zombie = Zombie.create(params[:zombie])
redirect_to @zombie
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With