This project is archived and is in readonly mode.
CSV library error using WEBrick
-
Rohit Arondekar
- 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 endThe 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
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
- State changed from new to invalid
-
Mark Winkler
Adding require for csv to config/application.rb solves it.