Using the the comma gem and exporting CSV files perfectly fine on my local environment. Also working on our staging environment which is running on an AWS instance.
ONLY failing on Heroku.
Heroku says:
2013-08-21T21:55:34.875724+00:00 app[web.1]: NoMethodError (undefined method `klass' for nil:NilClass):
2013-08-21T21:55:34.875724+00:00 app[web.1]: app/models/job.rb:220:in `block in <class:Job>'
2013-08-21T21:55:34.875724+00:00 app[web.1]: app/controllers/jobs_controller.rb:25:in `block (2 levels) in index'
2013-08-21T21:55:34.875724+00:00 app[web.1]: app/controllers/jobs_controller.rb:18:in `index'
And line 220 in my Job model is:
Comma do
...
customer :first_name
...
end
job.rb includes the line:
belongs_to :customer
And customer.rb has:
has_many :jobs
And as I mentioned this entire thing works great on my local box - I click the export button and out pops all the jobs, with each customer in the appropriate column.
For whatever reason it's only failing on Heroku.
I'm using Ruby 2.0.0-p0 on Heroku, Comma gem only verified up to 1.9.2 according to the documentation - BUT - I'm using Ruby 2.0.0-p0 on the staging server AND on my local environment and, again, it's working.
It's the 'klass" that's really throwing me off, because I don't have that anywhere in my code. I've read other threads about the same error and their solutions, but I don't have things like nested model forms and the like.
It is some issue with Heroku & Ruby 2.0 and associations? I've got the has_many and belongs_to on both sides, but still seems to be misunderstanding the association...
UPDATE
From the framework trace:
comma (3.1.0) lib/comma/extractors.rb:72:in `get_association_class' <====
comma (3.1.0) lib/comma/extractors.rb:55:in `block in method_missing'
comma (3.1.0) lib/comma/extractors.rb:48:in `each'
comma (3.1.0) lib/comma/extractors.rb:48:in `method_missing'
comma (3.1.0) lib/comma/extractors.rb:15:in `instance_eval'
comma (3.1.0) lib/comma/extractors.rb:15:in `results'
It turned out that this was a legitimate bug in Comma gem - https://github.com/comma-csv/comma/releases
I reported and they accepted, fixed, and released v 3.1.1