For a recent project, I had a couple views with code like this:
<% if @users.count == 0 %>
This worked perfectly in development mode... I rolled it out to prod mode and it exploded, saying that count was not a valid method of Array. I changed every instance to use Array#length instead and it seems to be working.
1) What is the reason for this difference in behavior?
2) Are there any other exciting differences between dev and prod modes that I should watch out for?
MORAL: Make sure your production hosting environment uses the same version of Ruby as your local development environment. :)
Thank you
Tom
The count
method is only available in Ruby 1.9 and up. I recommend you use the same version of Ruby as your server to avoid problems like this - a lot has changed in 1.9.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With