Why is Array.count available in dev mode but not in production?

For a recent project, I had several views with code like this:

<% if @users.count == 0 %> 

This worked fine in development mode ... I turned it into prod mode and it exploded, saying that the counter is not a valid Array method. I changed each instance to use the length of Array # and it seems to work.

1) What is the reason for this difference in behavior?

2) Are there any other interesting differences between the dev and prod modes that I should follow?

MORAL: make sure your production hosting environment uses the same version of Ruby as your local development environment. :)

thanks

Tom

+6
ruby ruby-on-rails
source share
2 answers

The count method is only available in Ruby 1.9 and later. I recommend using the same version of Ruby as your server to avoid such problems - a lot has changed in version 1.9.

+8
source share

omg, bluehost has Ruby 1.8.6, and now half of my application is down. Mostly because of this problem, with the score.

0
source share

All Articles