Why does RakeFileUtils get mixed into ActiveRecord::Base?

I’m running into a rather weird problem… I have a model with a
“link” attribute that isn’t working because it’s getting clobbered by
RakeFileUtils#link

It seems as soon as you require ‘rake’ that RakeFileUtils gets mixed
into ActiveRecord::Base

require ‘active_record’
=> true

RakeFileUtils
NameError: uninitialized constant RakeFileUtils
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/
active_support/dependencies.rb:443:in `load_missing_constant’

require ‘rake’
=> [“RakeFileUtils”, “FileList”, “RAKEVERSION”]

ActiveRecord::Base.include? RakeFileUtils
=> true

Any idea how this is happening exactly?

Even worse, the accessor method for the attribute seems to be getting
eventually defined in what seems to be a magical or non-deterministic
manner:

First time around:

#<Method: Channel(RakeFileUtils)#link>

Second time around:

#<Method: Channel#link>

My gut feeling is that RakeFileUtils really, really does not belong in
ActiveRecord::Base

Never mind, this is Rake’s fault. From rake.rb:

#############################################################################

Include the FileUtils file manipulation functions in the top level

module,

but mark them private so that they don’t unintentionally define

methods on

other objects.

include RakeFileUtils
private(*FileUtils.instance_methods(false))
private(*RakeFileUtils.instance_methods(false))

Hi Tony,

I am having the same problem, I have an AR model with a link field
which isn’t getting called because of Rake. This only just started
happening, what is the best way to solve this issue?

Thanks a bundle,

Josh

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