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:in `create''
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:
---------------------------------
<!--[form:customer]-->
<p><label for="customer_name">Name</label></p>
<p><%= text_field ''customer'',
''name'' %></p>
<p><label
for="customer_password">Password</label></p>
<p><%= password_field ''customer'',
''password'' %></p>
<p><label
for="customer_email">Email</label></p>
<p><%= text_field ''customer'',
''email'' %></p>
<!--[eoform:customer]-->
Why doesn''t it see the parameters I''m trying to send it?
why is the error happening?
TIA,
Elle
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On 24 Oct 2007, at 10:29, elle wrote:> > 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:in `create'' > > > My customer.rb class has: > ---------------------------------------- > def password(value) > write_attribute("password", Digest::SHA1.hexdigest(value)) > end > > > Why doesn''t it see the parameters I''m trying to send it? > why is the error happening? > >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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---