We ran this code last year in using ruby 1.9.3 and Rails 3.0 with no problems, but we now need to run it again this year following an upgrade and it is failing.
The error appears to be around parsing headers when importing a CSV file. The code is
ROOT_DIR = File.expand_path File.dirname(__FILE__)
csv_file = ROOT_DIR + '/holidays_2016.csv'
csv = CSV.read(csv_file, headers: true)
The error returned is
output error: #<NoMethodError: undefined method `table' for #<Object:0x007f82898e15a8>>
removing the headers: true option fixes the problem but I really do need the headers as they are used later in the code !
CSV.read
expects a hash as options parameter, not named parameters. It probably worked because of defaults, not because your code did not appear to have a bug. Take a look at source.CSV.read(csv_file, {headers: true})
should resolve your problem. – Aleksei MatiushkinCSV.read(csv_file, {return_headers: true})
of course. – Aleksei Matiushkin