So I had the same problem, turns out that it was because we had ruby
facets installed alongside acts_as_audited: 
http://facets.rubyforge.org/apidoc/index.html.
The issue being is that facets implements its own sum, which overrode
rails internal sum.  Rails internal sum will return 0 on an empty
array, while facets returns 0:

fawkes:audit awatkins$ ruby script/console
Loading development environment (Rails 2.3.3)
>> [].sum([]) {|a| nil}
=> []
>> quit
fawkes:audit awatkins$ sudo gem install facets
Successfully installed facets-2.8.0
1 gem installed
Installing ri documentation for facets-2.8.0...
Installing RDoc documentation for facets-2.8.0...
fawkes:audit awatkins$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'facets'
=> true
irb(main):003:0> [].sum([]) {|a| nil}
=> 0

Andrew


On Nov 27, 12:06 am, femto <[email protected]> wrote:
> observed_classes is [].
> I replied earlier, but the google post forum seems to
> went some wrong, so makes my post unsuccesful.
> Sorry for that.
>
> On 11月26日, 下午4时50分, "Jeffrey L. Taylor" <[email protected]> wrote:
>
>
>
> > Quoting femto <[email protected]>:
>
> > > Hello all, while I'm using acts_as_audited(on jruby platform),
> > > after vendored the acts_as_audited, it reports some error,
> > > line 167,
> > > # Start observing the declared classes and their subclasses.
> > >    def initialize
>
> > >      Set.new(observed_classes + observed_subclasses).each { |klass|
> > > add_observer! klass } #this line
> > >    end
> > > after some trace shows this one, when observed_classes is empty, will
> > > return 0(Fixnum) causes the
> > > above line to report error,
>
> > > def observed_subclasses
> > >        observed_classes.sum([]) { |klass| klass.send(:subclasses) }
> > > end
>
> > > so I changed it to this:
>
> > > def observed_subclasses
> > >        #observed_classes.sum([]) { |klass| klass.send(:subclasses) }
> > >        result = []
> > >        observed_classes.each do |klass|
> > >           result += klass.send(:subclasses)
> > >        end
>
> > >      end
> > > It this a bug?
>
> > What is definition of observed_classes?  When there are no observed classes,
> > does it return [] or nil?
>
> > Jeffrey

--

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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to