Hi, i have a model that extends AcitveRecord::Base called PhoneUser. This table has a field called hits in it. This is set to default at 0. When I try and increment the value for hits in a controller I get the following error wrong number of arguments (1 for 0) and points to line 57 My code is @phone_user = PhoneUser.find(uaid) @phone_user.hits += 1 @phone_user.save If I remove the line @phone_user.hits += 1 then it works fine, with no errors Has anyone got any ideas --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
line 57 is the line @phone_user.save On 27 Jul, 16:26, Iain Adams <aca04...-3Ch7lUbXYW61Qrn1Bg8BZw@public.gmane.org> wrote:> Hi, > > i have a model that extends AcitveRecord::Base called PhoneUser. This > table has a field called hits in it. This is set to default at 0. When > I try and increment the value for hits in a controller I get the > following error > > wrong number of arguments (1 for 0) and points to line 57 > > My code is > > @phone_user = PhoneUser.find(uaid) > @phone_user.hits += 1 > @phone_user.save > > If I remove the line @phone_user.hits += 1 then it works fine, with no > errors > > Has anyone got any ideas--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
read the rails doc look at the AR function increment! On Fri, 2007-07-27 at 15:34 +0000, Iain Adams wrote:> line 57 is the line > @phone_user.save > > On 27 Jul, 16:26, Iain Adams <aca04...-3Ch7lUbXYW61Qrn1Bg8BZw@public.gmane.org> wrote: > > Hi, > > > > i have a model that extends AcitveRecord::Base called PhoneUser. This > > table has a field called hits in it. This is set to default at 0. When > > I try and increment the value for hits in a controller I get the > > following error > > > > wrong number of arguments (1 for 0) and points to line 57 > > > > My code is > > > > @phone_user = PhoneUser.find(uaid) > > @phone_user.hits += 1 > > @phone_user.save > > > > If I remove the line @phone_user.hits += 1 then it works fine, with no > > errors > > > > Has anyone got any ideas > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---