0

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? :/

3
  • Try changing your duel_params to params.require(:duel).permit(:euro) Commented Aug 29, 2015 at 12:27
  • You have to do (:duel) instead of [:duel] Commented Aug 29, 2015 at 12:29
  • thanks guys - appreciate it! Commented Aug 29, 2015 at 12:39

1 Answer 1

2

You should change your duel_params to below

def duel_params
  params.require(:duel).permit(:euro)
end
Sign up to request clarification or add additional context in comments.

1 Comment

woooooooow - I had it before like that, just with the exception of [:duel] instead of (:duel)... thank you!!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.