Wrong number of arguments (0 for 1)

Hi,

When I am trying to update customer’s details (or even when trying to
create a new customer) I get this error:

ArgumentError in Admin/customerController#create
wrong number of arguments (0 for 1)
app/controllers/admin/customer_controller.rb:29:in password' app/controllers/admin/customer_controller.rb:29:increate’

My customer.rb class has:

def password(value)
write_attribute(“password”, Digest::SHA1.hexdigest(value))
end

My customer_controller.rb has:

def create
c = Customer.new(params[:customer])
if c.save
flash[:notice] = ‘Customer was successfully created.’
redirect_to :action => ‘list’
else
render :action => ‘new’
end
end

def edit
@page_title = ‘Editing Customer’
@customer = Customer.find(params[:id])
end

def update
@customer = Customer.find(params[:id])
if @customer.update_attributes(params[:customer])
flash[:notice] = ‘Customer was successfully updated.’
redirect_to :action => ‘show’, :id => @customer
else
render :action => ‘edit’
end
end

And my _form.rb has:

Name

<%= text_field 'customer', 'name' %>

Password

<%= password_field 'customer', 'password' %>

Email

<%= text_field 'customer', 'email' %>

Why doesn’t it see the parameters I’m trying to send it?
why is the error happening?

TIA,
Elle

On 24 Oct 2007, at 10:29, elle wrote:

I suspect the problem is that you’ve called your setter method
password instead of password=, which will cause problems when rails
tries to read the password (eg when displaying the form).

Fred

I suspect the problem is that you’ve called your setter method
password instead of password=, which will cause problems when rails
tries to read the password (eg when displaying the form).

Thanks Fred. You are right and it is fixed.
Cheers,
Elle