lib/dependent_restrict.rb in dependent_restrict-0.2.0 vs lib/dependent_restrict.rb in dependent_restrict-0.2.1
- old
+ new
@@ -1,10 +1,10 @@
require 'active_record'
require 'dependent_restrict/delete_restriction_error'
module DependentRestrict
- VERSION = '0.2.0'
+ VERSION = '0.2.1'
def self.included(base)
super
base.extend(ClassMethods)
@@ -43,9 +43,10 @@
has_many_without_restrict(association_id, options, &extension)
end
def has_and_belongs_to_many_with_restrict(association_id, options = {}, &extension)
reflection = if active_record_4?
+ raise ArgumentError, "dependent_restrict doesn't work with has_and_belongs_to_many. Use equivalent rails 4.1 has_many :through" if ActiveRecord::Reflection.respond_to? :create
restrict_create_reflection(:has_and_belongs_to_many, association_id, options, scope ||= {}, self)
else
create_reflection(:has_and_belongs_to_many, association_id, options, self)
end
add_dependency_callback!(reflection, options)