A Note With Heroku Stacks & Rails 3 + CSV
17 Dec 2010Tags: ruby on rails ruby ruby 1.9.2 heroku heroku stacks ruby csv fastercsv
So, if you’re using Rails 3 on Heroku, you need to know this very important thing when working with CSV’s. The regular stack for ruby on Heroku is default set to version 1.8.7, which means that it is using the version of ruby with the old CSV library in place instead of the new one where they took FasterCSV and integrated it in (soooo much faster).
With that in mind, if you have code like this:
csv_string = CSV.generate do |csv| # csv building end
You’ll end up with an error like this:
ArgumentError (wrong number of arguments (0 for 1)):
To fix it, you need to run this command to check which stack you’re on:
$ heroku stack * aspen-mri-1.8.6 bamboo-ree-1.8.7 bamboo-mri-1.9.2
And this one to migrate to the latest 1.9.2 stack:
$ heroku stack:migrate bamboo-mri-1.9.2 ----> Preparing to migrate myapp from aspen-mri-1.8.6 to bamboo-mri-1.9.2 ...
Don’t forget to do a git push to heroku once you migrate. You can force it with this command:
$ echo >> Rakefile && git commit -a -m "migrating to 1.9.2 stack" $ git push heroku master
Remember that the new 1.9.2 stack is officially in beta. If that isn’t acceptable, then use the FasterCSV gem instead but you may have to pull your own ruby version down to match (I didn’t try and find out). Hope this helps anyone else who’s had this error :)