I created a scaffolded template and get the following error:
ArgumentError in DuelsController#create wrong number of arguments (0 for 1)
Extracted source (around line #74):
# Never trust parameters from the scary internet, only allow the white list through.
def duel_params
params.require[:duel].permit(:euro, :authenticity_token)
end
end
Parameters are:
{"utf8"=>"✓",
"authenticity_token"=>"SxksBvZNjPuciScahht76K2fj8r3AWEGe0MGmPfJUfF84GKy8Z2dK8dMGRBRiQ4L1paHUKpdTs6YxUjt6K3nWA==",
"duel"=>{"euro"=>"5"},
"commit"=>"Create Duel"}
Code Controller
def create
@duel = Duel.new(duel_params)
respond_to do |format|
if @duel.save
format.html { redirect_to @duel, notice: 'Duel was successfully created.' }
format.json { render :show, status: :created, location: @duel }
else
format.html { render :new }
format.json { render json: @duel.errors, status: :unprocessable_entity }
end
end
end
# Never trust parameters from the scary internet, only allow the white list through.
def duel_params
params.require[:duel].permit(:euro, :authenticity_token)
end
Form
<h1>New Duel</h1>
<%= simple_form_for @duel do |d| %>
<%= d.input :euro %>
<%= d.button :submit %>
<% end %>
<%= link_to 'Back', duels_path %>
Where is the bug? :/
duel_paramstoparams.require(:duel).permit(:euro)(:duel)instead of[:duel]