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? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. On 2/26/07, rv dh <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > 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? > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Luke Ivers 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! -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---