Hello,
I’ve seen all sorts of places where people put their ‘require’
statements,
and I’m not sure what the best solution is. I’m currently using it
directly
in a model/csv_processor.rb:
require ‘fastercsv’
class CsvProcessor
def self.create_csv_table(file)
…
FCSV.parse(…
…
end
I’m calling this from controllers/loader_controller.db:
my_csv_table = CsvProcessor.create_csv_table(params[:file_ref])
Works perfectly. But generally, where is the place to put all those
require statements? Is it in config/environment.rb? Would it be correct
to add them just at the end of this file?
I already tried this with another “processor”, which needs the
ruby-plsql
gem. So I added at the end of environment.rb the statements:
require ‘ruby-plsql’
plsql.activerecord_class = ActiveRecord::Base
plsql.connection.autocommit = false
But this didn’t work. I couldn’t start webrick anymore. Having instead
the same statements at the beginning of model/plsql_processor.rb
works without problems.
Any help would be appreciated,
Martin