ruby-hyperloop / hyper-mesh

The project has moved to Hyperstack!! - Synchronization of active record models across multiple clients using Pusher, ActionCable, or Polling
https://hyperstack.org/
MIT License
22 stars 12 forks source link

inconsistent parameter passing in belongs_to method #93

Open catmando opened 6 years ago

catmando commented 6 years ago

some aliases of belongs_to have a signature like this: attr_name, scope = nil, opts = {}, but in reality, it must be attr_name, *args.

catmando commented 6 years ago

similar problem exists elsewhere in permissions:

class ActiveRecord::Base 
  def self.belongs_to(attr_name, *args)
      belongs_to_without_reactive_record_add_is_method(attr_name, *args).tap do
        define_method "#{attr_name}_is?".to_sym do |model|
          self.class.reflections[attr_name].foreign_key == model.id
        end
      end
    end
  end
end