Best location for generic classes?


#1

Say for instance, if I have a class that computes PI, where would the
best place to locate this class so that its accessible by the
controllers and helpers? What if I wanted to make this generic class
accessible to multiple RoR projects?

TIA.


#2

Make it a plugin if it’s mainly for use in Rails projects… if it’s
generally applicable to any Ruby project, you might want to make it a
Gem.

http://wiki.rubyonrails.com/rails/pages/Plugins
http://docs.rubygems.org/

  • james

#3

The lib folder is also viable. Remember to include it in your
environment.


#4

Is it possible to create a directory somewhere outside of the project
and include that directory in the path?


#5

Rick wrote:

Is it possible to create a directory somewhere outside of the project
and include that directory in the path?

You can sym link it:

ls -s reusable_stuff/your_plugin
your_rails_app/vendor/plugins/your_plugin

  • Scott