I wanted to have development code separate from the M V C of the rails code
so I added a folder lib/rubyscripts
Then in config/application.rb, added this line to load the code there automatically
config.autoload_paths << Rails.root.join("lib/rubyscripts")
After this, I can access code from this area in my controllers etc by using
require "class_name"
What is funny about this setup though is that, unlike in the controllers (where I can just use require "class_name" ) I still have to use the relative location rubyscripts/class_name in my spec files when referring to this code, don't exactly know why!
For example,
so I added a folder lib/rubyscripts
Then in config/application.rb, added this line to load the code there automatically
config.autoload_paths << Rails.root.join("lib/rubyscripts")
After this, I can access code from this area in my controllers etc by using
require "class_name"
What is funny about this setup though is that, unlike in the controllers (where I can just use require "class_name" ) I still have to use the relative location rubyscripts/class_name in my spec files when referring to this code, don't exactly know why!
For example,
spec/lib/rubyscripts/count_finder_spec.rb
Comments
Post a Comment