Forum: Ruby on Rails Problem concerning CSV Mime Type

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
rv d. (Guest)
on 2007-02-26 22:14
Hello,

I have an application that should be able to export a list of users as
CSV.

So I put
Mime::Type.register "text/csv", :csv
into my environment.rb, and added this code to my UserController's index
action:

      format.csv do
        require 'csv'
        CSV::Writer.generate(csv_string = "", ',') do |csv|
          csv << ["login","attribute1","attribute2"]
          @users.each { |user| csv << [user.login, user.email] }
        end
        send_data csv_string, :filename => "users.csv"
      end

All this is working fine, but each time I start my "ruby
script/console", I get the following error:
./script/../config/../config/../vendor/rails/actionpack/lib/action_controller/mime_type.rb:48:
warning: already initialized constant CSV

The error disappears, as soon as I remove the Mime Type entry in the
environment.rb. But of course this breaks the CSV export action.

So the app is behaving fine, but what causes the error and how can I get
rid of it?
Luke I. (Guest)
on 2007-02-26 22:19
(Received via mailing list)
See:
www.pdatasolutions.com/blog/archive/2007/02/*mime*_*type*_*csv*_bug_in_*
rails*_122.html

This, however, seems to be down, so just search for "rails mime type
csv" on
google, find the link to that page (first link, for me), and look at the
cached version.
rv d. (Guest)
on 2007-03-10 12:01
Luke I. wrote:
> See:
> www.pdatasolutions.com/blog/archive/2007/02/*mime*_*type*_*csv*_bug_in_*
> rails*_122.html
>
> This, however, seems to be down, so just search for "rails mime type
> csv" on
> google, find the link to that page (first link, for me), and look at the
> cached version.

Thank you Luke!
This topic is locked and can not be replied to.