Rails n00b question. I am creating a plain old Ruby object in Rails. But I am not sure if there is a standard location in the app that I should put this object.
Thanks
Several choices, but the lib
directory is the most common.
If you need to initialize the code, the most common place is config/initializers
.
So you might have:
lib/mystuff.rb
and:
config/initializers/mystuff.rb
lib/mystuff.rb
contains your ruby code.
config/initializers/mystuff.rb
contains code that initializes your stuff, whatever Ruby files that are found in config/initializers
are run when Rails boots up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With