RubyonRails wrong number of arguments

31 Views Asked by At

I am not a Ruby developer but I have an application that I inherited that runs on it. I am getting the below error:

wrong number of arguments (given 1, expected 0)

Code having problem is:

def destroy
   @user.destroy(params[:id]) #This is the line that my ArgumentError pointed to
   respond_to do |format|
     format.html { redirect_to users_url, notice: 'User was successfully destroyed.' }
     format.json { head :no_content }
   end
end

Any update to code or other places I need to look would be much appreciated.

I tried removing the (params) but that ended up creating other issue. I have read through other posts and did not see one using params

1

There are 1 best solutions below

1
mnort9 On

destroy takes no paramaters. You're already calling it on the instance variable.

@user.destroy

You may be confusing the class method with the instance method.