views:

28

answers:

1

I recently ran into an odd error that only occurred in production mode.

I was using the paths of glory gem that defines the class Achievement (http://github.com/paulca/paths_of_glory/blob/master/app/models/achievement.rb).

In the base class, level is defined:

def level(level, options = {})
  levels << {:level => level, :quota => options[:quota]}
end

The paths of glory gem works by having you create models that inherit from the base achievement model.

In an effort to add an additional method to the base Achievement class, we (erroneously, in retrospect) created a new models/aachievements.rb (yes, intentional spelling error, since Rails will try to load Achievement if we called it achievements.rb) file, however, rather than re-opening the class, we redefined the class. Because our redefinition didn't include level, when we deployed to production, we hit an error that level was an undef method.

The question is, why didn't this error manifest itself in development mode? The gem and classes were the same in both.

Any ideas?

+1  A: 

Unless you namespaced or deleted the constant you really still reopened the class, or yours was defined first then reopened by the gem.

Anyways, turn on cache classes in development.rb in environments and see what happens.

Joe Martinez
Well, this error occurred in production, so would that mean it occurs when cached_classes are on?
shedd
That's why I said to try it with cached classes on in development as well - lemme know what happens.
Joe Martinez