# Why does RakeFileUtils get mixed into ActiveRecord::Base?

**URL:** <https://www.ruby-forum.com/t/why-does-rakefileutils-get-mixed-into-activerecord-base/176829>\
**Category:** Rails\
**Created:** [October 6, 2009, 7:08pm UTC](https://www.ruby-forum.com/t/why-does-rakefileutils-get-mixed-into-activerecord-base/176829 "2009-10-06T19:08:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![murfhy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d26b3c/32.png) [@murfhy](https://www.ruby-forum.com/u/murfhy)\
**Post date:** [October 6, 2009, 7:08pm UTC](https://www.ruby-forum.com/t/why-does-rakefileutils-get-mixed-into-activerecord-base/176829/1 "2009-10-06T19:08:22Z")

</div>

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:

> <https://gist.github.com/202477>

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

---

<div class="post-metadata">

**Author:** ![murfhy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d26b3c/32.png) [@murfhy](https://www.ruby-forum.com/u/murfhy)\
**Post date:** [October 6, 2009, 8:45pm UTC](https://www.ruby-forum.com/t/why-does-rakefileutils-get-mixed-into-activerecord-base/176829/2 "2009-10-06T20:45:32Z")

</div>

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))

---

<div class="post-metadata">

**Author:** ![murfhy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d26b3c/32.png) [@murfhy](https://www.ruby-forum.com/u/murfhy)\
**Post date:** [October 20, 2009, 2:21pm UTC](https://www.ruby-forum.com/t/why-does-rakefileutils-get-mixed-into-activerecord-base/176829/3 "2009-10-20T14:21:07Z")

</div>

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
