# ArgumentError

**URL:** <https://discuss.rubyonrails.org/t/argumenterror/19682>\
**Category:** rubyonrails-talk\
**Created:** [October 25, 2007, 7:37am UTC](https://discuss.rubyonrails.org/t/argumenterror/19682 "2007-10-25T07:37:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [October 25, 2007, 7:37am UTC](https://discuss.rubyonrails.org/t/argumenterror/19682/1 "2007-10-25T07:37:25Z")

</div>

> i met an error that goes like this (even though i followed the book word for word)

but not symbol for symbol :\_

> > >
> 
> ArgumentError in Login#add\_user Showing app/views/login/add\_user.rhtml where line #16 raised:
> 
> wrong number of arguments (0 for 1)
> 
> Extracted source (around line #16): 16: \<%= form.password\_field :password, :size =\> 40 %\>
> 
> &nbsp;&nbsp;def password &nbsp;&nbsp;&nbsp;&nbsp;@password &nbsp;&nbsp;end
> 
> def password(pwd) &nbsp;&nbsp;&nbsp;@password = pwd &nbsp;&nbsp;&nbsp;create\_new\_salt &nbsp;&nbsp;&nbsp;self.hashed\_password = User.encrypted\_password(self.password, self.salt) end

So line 16 is trying to read the password attribute, ie it tries to call the password method. You've defined the password method as taking one argument, so it all falls over. You probably meant def password=(pwd) &nbsp;&nbsp;&nbsp;@password = pwd &nbsp;&nbsp;&nbsp;... end

Fred

---

<div class="post-metadata">

**Author:** ![Rick\_DeNatale](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Rick\_DeNatale](https://discuss.rubyonrails.org/u/Rick_DeNatale)\
**Post date:** [October 25, 2007, 5:41pm UTC](https://discuss.rubyonrails.org/t/argumenterror/19682/2 "2007-10-25T17:41:07Z")

</div>

Just to beat the h3ll out of the obvious. He RE-defined the password method.

The fact that Ruby considers only the method name and not the parameters is something which trips up folks who have used languages like C++ and Java and are expecting to be able to overload methods.
