# Using ActiveRecord outside of Rails error

**URL:** <https://www.ruby-forum.com/t/using-activerecord-outside-of-rails-error/88630>\
**Category:** Rails\
**Created:** [March 13, 2007, 6:23am UTC](https://www.ruby-forum.com/t/using-activerecord-outside-of-rails-error/88630 "2007-03-13T06:23:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nappin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f475e1/32.png) [@nappin](https://www.ruby-forum.com/u/nappin)\
**Post date:** [March 13, 2007, 6:23am UTC](https://www.ruby-forum.com/t/using-activerecord-outside-of-rails-error/88630/1 "2007-03-13T06:23:49Z")

</div>

Hi,  
I have a script which is using ActiveRecord for database queries outside  
of a rails app. It seems to work fine for doing finds on models, but  
everytime I try to create a new model object and then save it, I always  
get the error:  
MyModel.new({:name=\>‘foo’}).save gives  
NoMethodError: undefined method `read\_inheritable\_attribute’ for  
#MyModel:0x251f7d8

I’ve got a require for active\_support. Is there anything else I have to  
do to get this to work?  
Thanks,  
Ray

---

<div class="post-metadata">

**Author:** ![nappin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f475e1/32.png) [@nappin](https://www.ruby-forum.com/u/nappin)\
**Post date:** [March 13, 2007, 9:30am UTC](https://www.ruby-forum.com/t/using-activerecord-outside-of-rails-error/88630/2 "2007-03-13T09:30:57Z")

</div>

Hmm well after some investigating I’ve figured out what’s causing the  
problem…  
To give some background, I’m trying to use my models from my rails  
project in an outside ruby script. So I have my models live in a sub  
folder of the ruby app (via svn externals) and then I use them in my  
ruby script. However, one of these models is using the rails plugin  
validates\_multiparameter\_assignments. Unfortunately I don’t really need  
this plugin in my script, but I really want to use the same model files  
from the rails app so I have to live with it. Everytime I tried to use  
this model in my ruby script I’d get errors saying the  
validates\_multiparameter\_assignments method didnt exist. In order to  
get it to work, I required all the plugin files and used the line:  
ActiveRecord::Base.send :include,  
ActiveRecord::Validations::ClassMethods

While this got rid of the errors and allowed me to do finds on the  
model, this line however, seemed to have an adverse effect on the  
save/create methods of ActiveRecord giving me the missing active\_support  
methods I had in my previous post.

When I remove the include statement, I don’t get any errors and  
everything works fine. So somehow this include/plugin is affecting  
things.

For the time being, I’m just copying the troublesome rail’s model into  
my script without the plugin stuff and everything is working,  
unfortunately its not very dry.

If anyone has any light to shed on this, it’d be a big help! Thanks.

Cheers,  
Ray

Raymond O’Connor wrote:

> Hi,  
> I have a script which is using ActiveRecord for database queries outside  
> of a rails app. It seems to work fine for doing finds on models, but  
> everytime I try to create a new model object and then save it, I always  
> get the error:  
> MyModel.new({:name=\>‘foo’}).save gives  
> NoMethodError: undefined method `read\_inheritable\_attribute’ for  
> #MyModel:0x251f7d8
> 
> I’ve got a require for active\_support. Is there anything else I have to  
> do to get this to work?  
> Thanks,  
> Ray
