I am doing the above exercise on railsforzombies.org, and I simply cannot figure out why it keeps telling me I am not using strong parameters. I am using the examples shown in the video as a guide, but I keep getting the message:
"Did not create a new Zombie using Rails 4 Strong Parameters."
Here is my code:
class ZombiesController < ApplicationController
def create
@zombie = Zombie.create(params[:zombie])
redirect_to @zombie
end
private
def zombie_params
params.require(:zombie).permit([:name, :graveyard])
end
end
Here is the example which I am basing my solution off of: (I can't post pictures yet)
https://i.sstatic.net/Jyw8n.jpg
I have read the solution listed at Rails for Zombies Lab 4 > Exercise 3 However, this example does not solve the 'Strong Parameters' error. I also cannot comment on that topic, so I have started a new one for Rails 4.
the method zombie_params
filters the parameters correctly.
But you're not using that method when you create the Zombie
object.
Instead of doing
@zombie = Zombie.create(params[:zombie])
use the method
@zombie = Zombie.create(zombie_params)