This project is archived and is in readonly mode.
CSV library error using WEBrick
Reported by Mark Winkler | June 14th, 2010 @ 07:03 PM | in 3.x
Rails 3.0 beta4
Ruby 1.9.2preview3
uninitialized constant Invoice::CSV thrown when invoking CSV.generate in model using WEBrick.
The error does not occur when run through console.
require 'csv'
class Invoice < ActiveRecord::Base
csv_content = CSV.generate do |csv|
end
end
Comments and changes to this ticket
-
Rohit Arondekar June 15th, 2010 @ 03:56 AM
- Milestone set to 3.x
- Tag set to missing requires, rails 3, csv
- Assigned user set to Pratik
Confirmed on Rails master and Ruby 1.9.2-head.
This is a very strange issue. I used CSV inside a class method on Post model. If I open the rails console, and try Post.foo, it works.
However if I do reload! — it stops working.
The model:
require 'csv' class Post < ActiveRecord::Base def self.foo csv_content = CSV.generate { |csv| } end end
The console output:
Loading development environment (Rails 3.0.0.beta4) ruby-1.9.2-head > Post.foo => "" ruby-1.9.2-head > reload! Reloading... => true ruby-1.9.2-head > Post.foo NameError: uninitialized constant Post::CSV from /home/rohit/bugmash/trythreadsafe/app/models/post.rb:5:in `foo' from (irb):3 from /home/rohit/remote-repos/rails_patches/working4/railties/lib/rails/commands/console.rb:47:in `start' from /home/rohit/remote-repos/rails_patches/working4/railties/lib/rails/commands/console.rb:8:in `start' from /home/rohit/remote-repos/rails_patches/working4/railties/lib/rails/commands.rb:23:in `<top (required)>' from script/rails:6:in `require' from script/rails:6:in `<main>'
Curiously enough, I tried the same thing with YAML, Digest and Zlib and things worked fine. I also tried on a Rails 2.x app on 1.8.7 and things worked.
Can somebody please try on Rails 2.x and 1.9.2-preview3 or -head? Looks like a CSV lib issue on 1.9.2.
-
Rohit Arondekar June 19th, 2010 @ 08:54 AM
Mark, can you try adding the require for csv inside config/application.rb ? After the Bundler.require should do fine. I think this should solve your issue. Please update the ticket if this solves your problem. :)
-
Rizwan Reza June 19th, 2010 @ 05:21 PM
- State changed from new to invalid
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>