I need to use the CSV module built into Ruby 1.9.2, and, in order to do this, I need to do require 'csv'.
In Rails 3, where is the proper place to put this require? I have seen examples where it’s at the top of the file it’s used in.
I have also see an example where it’s put in config/initializers/csv_init.rb.
Is there a rule of thumb here? If I need it in multiple files, put it in an initializer, if only one put it in the file itself?
Put it in ‘config/application.rb’. (See “Configuring Rails Applications“).
In general, do this stuff in a central place and document it. The person maintaining your application will appreciate it when some future Ruby or Rails version breaks all kinds of backward compatibility.