Commit e0f366627db9dde817dd768b0168d8ee7ba44d3a

Authored by Victor Costa
1 parent a01ff913

rails3: fix conflict with two activated plugins that has extensions.

Steps to reproduce:
  - Enable vote plugin;
  - Enable work_assignment plugin;
  - Create an UploadedFile;
  - When remove the created UploadedFile: NoMethodError: undefined method `association_class' for nil:NilClass
Showing 1 changed file with 16 additions and 0 deletions   Show diff stats
config/initializers/active_record_extensions.rb
1 1 require 'upload_sanitizer'
  2 +
  3 +module ActiveRecordExtension
  4 +
  5 + extend ActiveSupport::Concern
  6 +
  7 + module ClassMethods
  8 + def reflect_on_association(name)
  9 + reflection = super
  10 + if reflection.nil? && self.superclass.respond_to?(:reflect_on_association)
  11 + reflection = self.superclass.reflect_on_association(name)
  12 + end
  13 + reflection
  14 + end
  15 + end
  16 +end
  17 +ActiveRecord::Base.send(:include, ActiveRecordExtension)
... ...