I have a rake task I created and inside it I have the line
number = rand(1..10)
When I run this on my development machine everything is ok, however, when I run it on Heroku I’m returned an error
rake aborted!
can't convert Range into Integer
/app/lib/tasks/sample_data.rake:57:in `rand'
I should note that earlier in the rake task I ran rand(111) without fail. I have to assume the problem is caused by me setting a start and end point for rand to choose from.
So the big questions is, why does Heroku treat rand as a range and not as an integer and how do I fix this?
Range support in
rand()was added in Ruby 1.9.3. You’re likely running 1.9.2 (the default) on Heroku. You can run 1.9.3 on Heroku by addingruby "1.9.3"to your Gemfile.