@@ -18,11 +18,15 @@ class Support
1818
1919 def initialize ( model_class , options )
2020 @model_class = model_class
21+
22+ # Detect if we're using SQLite and disable advisory locks
23+ default_with_advisory_lock = !connection . adapter_name . downcase . include? ( 'sqlite' )
24+
2125 @options = {
2226 :parent_column_name => 'parent_id' ,
2327 :dependent => :nullify , # or :destroy or :delete_all -- see the README
2428 :name_column => 'name' ,
25- :with_advisory_lock => true ,
29+ :with_advisory_lock => default_with_advisory_lock ,
2630 :numeric_order => false
2731 } . merge ( options )
2832 raise ArgumentError , "name_column can't be 'path'" if options [ :name_column ] == 'path'
@@ -34,14 +38,10 @@ def initialize(model_class, options)
3438 def hierarchy_class_for_model
3539 parent_class = model_class . module_parent
3640 hierarchy_class = parent_class . const_set ( short_hierarchy_class_name , Class . new ( model_class . superclass ) )
37- use_attr_accessible = use_attr_accessible?
38- include_forbidden_attributes_protection = include_forbidden_attributes_protection?
3941 model_class_name = model_class . to_s
4042 hierarchy_class . class_eval do
41- include ActiveModel ::ForbiddenAttributesProtection if include_forbidden_attributes_protection
4243 belongs_to :ancestor , class_name : model_class_name
4344 belongs_to :descendant , class_name : model_class_name
44- attr_accessible :ancestor , :descendant , :generations if use_attr_accessible
4545 def ==( other )
4646 self . class == other . class && ancestor_id == other . ancestor_id && descendant_id == other . descendant_id
4747 end
0 commit comments