To_ary removed from ActiveRecord

I was experiment in the console and I did this:

c = Client.new

a = c.to_a

which gave this:

(irb):14: warning: default `to_a’ will be obsolete

so, since to_a is depreciated then I will use to_ary, right? No. you
can’t.

a = c.to_ary

NoMethodError: undefined method to_ary' for #<Client:0xb7f08b80> from /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/attribute_methods.rb:205:inmethod_missing’
from (irb):15
from :0

Now, the interesting thing here is that ‘to_ary’ was removed from
ActiveRecord on ticket 177 way back before 1.0. Apparently, the method
missing handling of ActiveRecord makes ‘to_ary’ redundant. So, my
questions are, why doesn’t AR provide me with a dynamic ‘to_ary’ method
when I call it from the console and what am I suppose to load in the
console to get this method?

I fully realize that I can continue to use to_a, as I shall since I have
no option. But what happens when to_a actually disappears? Not that it
ever will in reality, but that depreciation warning is annoying none the
less and I do not wish to turn off all warnings to get rid of one.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs