Forum: Ruby on Rails Custom command line libraries for controllers and rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Berlin B. (Guest)
on 2006-05-29 23:52
(Received via mailing list)
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/newforums
also checkout alpha version of botverse:
http://www.newspiritcompany.com:8086/universe_home
This topic is locked and can not be replied to.