# Two ActiveRecords OK?

**URL:** <https://www.ruby-forum.com/t/two-activerecords-ok/129599>\
**Category:** Rails\
**Created:** [February 19, 2008, 11:58pm UTC](https://www.ruby-forum.com/t/two-activerecords-ok/129599 "2008-02-19T23:58:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@newbie](https://www.ruby-forum.com/u/newbie)\
**Post date:** [February 19, 2008, 11:58pm UTC](https://www.ruby-forum.com/t/two-activerecords-ok/129599/1 "2008-02-19T23:58:46Z")

</div>

I have a question regarding the compatbility of Rails and generic  
ActiveRecord.

I am running Rails 2.0.2 on a Linux box. My ruby version is 1.8.6.

I need to read from/write to some tables in the same rails production  
databases FROM OUTSIDE OF RAILS ENVIRONMENT. According to the  
following article, there are at least three ways to do this is Ruby:

1. Database driver; 2. DBI; 3. ActiveRecord.

> **[Ruby DBI: Database Access](http://www.troubleshooters.com/codecorn/ruby/database/index.htm)**
>
> A website devoted to the Ruby programming language

Of course the 3rd method (using the ActiveRecord) seems the most  
natural one given the grammar is the same as in Rails. My question is  
as follows.

As we know, ActiveRecord is part of Rails. If I use the 3rd method to  
access the database, will that actually cause any problems to Rails,  
because I am using the same ActiveRecord in two places?

Thanks!

---

<div class="post-metadata">

**Author:** ![newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@newbie](https://www.ruby-forum.com/u/newbie)\
**Post date:** [February 20, 2008, 12:09am UTC](https://www.ruby-forum.com/t/two-activerecords-ok/129599/2 "2008-02-20T00:09:58Z")

</div>

On 2/19/08, newbie [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> As we know, ActiveRecord is part of Rails. If I use the 3rd method to  
> access the database, will that actually cause any problems to Rails,  
> because I am using the same ActiveRecord in two places?

No.

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)

---

<div class="post-metadata">

**Author:** ![newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@newbie](https://www.ruby-forum.com/u/newbie)\
**Post date:** [February 20, 2008, 12:11am UTC](https://www.ruby-forum.com/t/two-activerecords-ok/129599/3 "2008-02-20T00:11:08Z")

</div>

No, it won’t cause any problems. Rails is really a gem (hence the  
common gem install rails --include-dependencies) and ARec is just one  
of its gem dependencies. Since it’s on your system as a gem you can  
use it in any Ruby project. You won’t have the framework to issue the  
correct top-level include, but I’m sure you’ll get that worked out!

---

<div class="post-metadata">

**Author:** ![newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@newbie](https://www.ruby-forum.com/u/newbie)\
**Post date:** [February 20, 2008, 5:57pm UTC](https://www.ruby-forum.com/t/two-activerecords-ok/129599/4 "2008-02-20T17:57:40Z")

</div>

Got it! Thanks a lot!
