Module: ActiveRecordEx::AssocOrdering::ClassMethods
- Defined in:
- lib/active-record-ex/assoc_ordering.rb
Instance Method Summary collapse
- #accepts_nested_attributes_for(assoc_name, options = {}) ⇒ Object
- #has_many(assoc_name, scope = nil, options = {}, &extension) ⇒ Object
Instance Method Details
#accepts_nested_attributes_for(assoc_name, options = {}) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/active-record-ex/assoc_ordering.rb', line 23 def accepts_nested_attributes_for(assoc_name, = {}) order_field = .delete(:order_on) allow_destroy = [:allow_destroy] || [:assume_destroy] super return unless order_field define_attribute_setter(assoc_name, order_field, allow_destroy) end |
#has_many(assoc_name, scope = nil, options = {}, &extension) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/active-record-ex/assoc_ordering.rb', line 10 def has_many(assoc_name, scope = nil, = {}, &extension) order_field = scope.is_a?(Hash) ? scope.delete(:order_on) : .delete(:order_on) if ActiveRecord::VERSION::MAJOR < 4 super(assoc_name, scope || {}, &extension) else super end opts = (scope.is_a?(Hash) ? scope : ) return unless order_field define_model_setter(assoc_name, order_field) end |