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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Feb 19, 11:53 am, Martin Berli <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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? >Well if it''s a gem then using config.gem inside config/environment.rb is usually the way to go. You don''t want to just stick things at the bottom of environment.rb - in production mode your app''s code gets loaded before the bottom of environment.rb gets executed. If you put stuff in an initializer (ie in a file in config/initializers) then it will get run early enough. Fred> 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 > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.