# Custom command line libraries for controllers and rails

**URL:** <https://www.ruby-forum.com/t/custom-command-line-libraries-for-controllers-and-rails/95345>\
**Category:** Rails\
**Created:** [May 29, 2006, 9:52pm UTC](https://www.ruby-forum.com/t/custom-command-line-libraries-for-controllers-and-rails/95345 "2006-05-29T21:52:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Berlin\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@Berlin\_B](https://www.ruby-forum.com/u/Berlin_B)\
**Post date:** [May 29, 2006, 9:52pm UTC](https://www.ruby-forum.com/t/custom-command-line-libraries-for-controllers-and-rails/95345/1 "2006-05-29T21:52:14Z")

</div>

I have a library that is basically used on the command-line. I am  
trying to fit it in for my rails application. So far it works, but I  
was worried about how rails does caching or anything else. Basically,  
is this an ok approach.

So far, I put the library in RAILS\_APP/lib/bot.rb

And ‘bot.rb’ contains a class ‘VM’.

I have a controller:

BotController…

And I put this at the top:

require File.dirname( **FILE** ) + ‘/…/…/lib/bot’

And then I just allocate an instance in one my controller methods and  
that is it.

Of course, there is one instance per request which is a little  
wasteful. But, that is my initial approach thus far.

–  
Berlin B.  
(ramaza3 on freenode)  
[http://www.newspiritcompany.com](http://www.newspiritcompany.com)  
[http://www.newspiritcompany.com/newforums](http://www.newspiritcompany.com/newforums)  
also checkout alpha version of botverse:  
[http://www.newspiritcompany.com:8086/universe\_home](http://www.newspiritcompany.com:8086/universe_home)
