CSV::Writer and Rails 1.2.3


#1

This seems to no longer work…

http://www.ruby-doc.org/core/classes/CSV/Writer.html

from my console session (lifting code from my application)

@qm_monitorings = QmMonitoring.find(:all)

=> [#<QmMonitoring:0xb74d72b0
@attributes={“qm_mon_month_year”=>“2007-03-01”, “facility_id”=>“12”,
“id”=>“1”, “num_charts_reviewed”=>“5”}>]

report = StringIO.new
=> #StringIO:0xb74d59b0

CSV::Writer.generate(report, ‘,’) do |csv|
?> csv << %w(Facility Date Charts_reviewed Type Qty)

@qm_monitorings.each do |qm|
?> @qm_monitoring_data =
QmMonitoringData.find(:all, :conditions => [“qm_monitoring_id = ?”,
qm.id], :order => ‘qm_data_type’)

    for qm_monitoring_data in @qm_monitoring_data
      csv << [qm.facility.name, qm.qm_mon_month_year,

qm.num_charts_reviewed, qm_monitoring_data.qm_data_type,
qm_monitoring_data.qm_charts]

    end
  end
end

NameError: uninitialized constant CSV

from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:266:in
`load_missing_constant’

from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:452:in
`const_missing’

from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:464:in
`const_missing’
from (irb):4


Craig W. removed_email_address@domain.invalid


#2

… try adding require ‘csv’ … i had the same problem with the
CSV::Reader.parse


#3

yep…thanks

It seems that the biggest problems that I have had in the Rails 1.2.x
upgrade came from Ruby modules

Craig

On Fri, 2007-04-13 at 10:48 -0700, jimache wrote:

QmMonitoringData.find(:all, :conditions => [“qm_monitoring_id = ?”,
from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependen�cies.rb:266:in `load_missing_constant’


Craig W. removed_email_address@domain.invalid