Cliff Moon on 30 May 2007 02:58:53 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PhillyOnRails] AR accessor problem


Aha, self.cash += tx.gain works. I'll have to sanitize the java specifics out of the test and see if it does the same thing on MRI. Thanks.

Evan Weaver wrote:
Trying using:

self.cash = self.cash + tx.gain

or even

cash = self.cash + tx.gain

The syntax parser might be thinking "cash" is a local.

Evan

On 5/29/07, Cliff Moon <cliff@chariotsolutions.com> wrote:
I'm trying to track down whether or not a problem I'm having is specific
to the JRuby platform, or it's an inherent limitation of AR.  What I'm
trying to do is something like:

cash += tx.gain

where tx is another AR object and gain is a calculated field which isn't
persistent.  My unit tests keep telling me that I'm trying to call nil.+
at this line, despite cash having been explicitly set.  Curiously, the
problem occurs exactly the same when the code is:

cash = cash + tx.gain

The following work:

blah = cash + tx.gain
cash = blah

and

self[:cash] = cash + tx.gain

So anyone have a clue what's going on here?  Is this just a quirk of AR
that I've been lucky enough not to have run into until now, or mightn't
this be something JRuby related?
_______________________________________________
To unsubscribe or change your settings, visit:
http://lists.phillyonrails.org/mailman/listinfo/talk




_______________________________________________ To unsubscribe or change your settings, visit: http://lists.phillyonrails.org/mailman/listinfo/talk