Today I spend my time with little project for my mom’s shop (Aom gift shop). I was trying to create a “add user” function in my controller. but this error show up when I try to do this

@new_user = User.new(params[:new_user])

when I attempt to view the add_user page. this error show up.

ArgumentError: wrong number of arguments (1 for 0)

So that means the user object can’t receive parameter more than zero.

Then I look up at my model called “User” and I found that I have an initialize method that is not receive any parameter

def initialize()

@administrator = “am”
@user = “us”

end

I figure out that I need to do something with my initialize method. Actually if you have used Java or C# or maybe other languages. Initialize method in ruby is just like a regular Constructor for other languages.

Anyway I changed my initialize method to be like this, and it works

def initialize(*params)
super(*params)
@administrator = “am”
@user = “us”

end

Created by “WhenURnotAround”