# Re-Use of Rails generated ActiveRecord classes

**URL:** <https://www.ruby-forum.com/t/re-use-of-rails-generated-activerecord-classes/66186>\
**Category:** Rails\
**Created:** [August 23, 2006, 9:32pm UTC](https://www.ruby-forum.com/t/re-use-of-rails-generated-activerecord-classes/66186 "2006-08-23T21:32:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![metrix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/48db29/32.png) [@metrix](https://www.ruby-forum.com/u/metrix)\
**Post date:** [August 23, 2006, 9:32pm UTC](https://www.ruby-forum.com/t/re-use-of-rails-generated-activerecord-classes/66186/1 "2006-08-23T21:32:20Z")

</div>

Hello. I’m doing a litle research about Rails. I installed Ruby and  
Rails, chose an IDE, read a few tutorials and bought a book. I’m just  
trying to get the feel of it right now.

I might want to build a billing system with RoR. I understand RoR  
generates ActiveRecord classes for you, called models, and you can  
include business logic in the models. I would problably add methods to  
these models, and those methods will contain business logic…things  
like:

Customer.UpdateBalance  
Customer.Cancel  
and so on…

Can these Models be used as-is in a Ruby script outside of Rails? My  
goal would be to not repeat the business logic by using the RoR  
generated models in any kind of maintenance script that would run on a  
scheduled basis. That would include scripts doing things like:

-emailing past due notices  
-creating invoices  
-processing credit card payments  
…and more

How do people normally these situations this with RoR applications?

Thanks.

---

<div class="post-metadata">

**Author:** ![metrix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/48db29/32.png) [@metrix](https://www.ruby-forum.com/u/metrix)\
**Post date:** [August 24, 2006, 12:57am UTC](https://www.ruby-forum.com/t/re-use-of-rails-generated-activerecord-classes/66186/2 "2006-08-24T00:57:47Z")

</div>

Cool. Thanks for the link.

I kept searching for something like Using Models outside Rails and I  
wasn’t getting any hits.

---

<div class="post-metadata">

**Author:** ![metrix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/48db29/32.png) [@metrix](https://www.ruby-forum.com/u/metrix)\
**Post date:** [August 24, 2006, 12:44am UTC](https://www.ruby-forum.com/t/re-use-of-rails-generated-activerecord-classes/66186/3 "2006-08-24T00:44:45Z")

</div>

On Aug 23, 2006, at 12:32 PM, Brandon C. wrote:

> -creating invoices  
> -processing credit card payments  
> …and more
> 
> How do people normally these situations this with RoR applications?
> 
> Thanks.

Hey Brandon-

```
Welcome to rails ;) Yeah you can use your ActiveRecord models

```

outside of rails pretty easily. So you can write your business logic  
in the models and not have to duplicate it elsewhere.

[http://wiki.rubyonrails.com/rails/pages/HowToUseActiveRecordOutsideRails](http://wiki.rubyonrails.com/rails/pages/HowToUseActiveRecordOutsideRails)

Cheers-  
-Ezra
