pinnymz / migration_comments

Comments for your migrations
MIT License
173 stars 31 forks source link

Loading annotate/annotate_models breaks ActiveRecord dynamic finders #2

Closed pinnymz closed 12 years ago

pinnymz commented 12 years ago

'annotate/annotate_models.rb' uses a monkey patched :method_missing to get around the problem of recognizing unknown macros ('acts_as_something' and the like). This monkey patch is only meant to be loaded when running the rake task to create annotations.

Unfortunately, we are requiring the 'annotate/annotate_models.rb' file to load in order to modify the output with comments. If we remove the requirement, our modification hook will never be inserted because the environment (and all gems) are loaded by the annotation rake task before the 'annotate/annotate_models.rb' file.

We'll need to find an alternative hooking method that doesn't require including the 'method_missing' monkey patch.

pinnymz commented 12 years ago

As a possible workaround, see this commit that moves the monkey patch to a separate file that only loads when running the rake task - https://github.com/pinnymz/annotate_models/commit/aae82380edd8561944402ada717239c4b0b98e27

pinnymz commented 12 years ago

This issue was fixed in ctran/annotate_models by integrating the proposed patch - see https://github.com/ctran/annotate_models/pull/73