[Rails] Re: Using an unsaved object
Eric Anderson
eric at afaik.us
Wed Jan 19 22:33:57 GMT 2005
Eric Anderson wrote:
> My problem is why
> is @attributes equal to nil?
As indicated on my previous post I fixed my problem where I was not able
to do:
usr = User.new
usr.username
because I forgot to call super in my initialize method. Now I have a
related but different problem. Now I am trying to assign a value to the
username. So I have
... Controller Definition ...
def save
usr = User.new
usr.username = "foobar"
end
... Controller Definition ...
When I do this I get the following:
wrong number of arguments (2 for 1)
/app/controllers/user_controller.rb:43:in `method_missing'
/app/controllers/user_controller.rb:43:in `save'
/app/controllers/application.rb:30:in `process'
Line 43 of user_controller is 'usr.username = "foobar"'. Any ideas? I
can call the write_attribute method fine but for some reason cannot use
the method_missing auto generated methods.
Eric
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature
Url : http://one.textdrive.com/pipermail/rails/attachments/20050119/74bd181a/signature.bin
More information about the Rails
mailing list