Module: ActiveRecord::ActsAs::OrderableTable::ClassMethods
- Defined in:
- lib/active_record/acts_as/orderable_table.rb
Instance Attribute Summary collapse
-
#ordinal_field ⇒ Object
readonly
Returns the value of attribute ordinal_field.
-
#starts_from ⇒ Object
readonly
Returns the value of attribute starts_from.
Instance Method Summary collapse
Instance Attribute Details
#ordinal_field ⇒ Object (readonly)
Returns the value of attribute ordinal_field.
9 10 11 |
# File 'lib/active_record/acts_as/orderable_table.rb', line 9 def ordinal_field @ordinal_field end |
#starts_from ⇒ Object (readonly)
Returns the value of attribute starts_from.
9 10 11 |
# File 'lib/active_record/acts_as/orderable_table.rb', line 9 def starts_from @starts_from end |
Instance Method Details
#acts_as_orderable_table(options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/active_record/acts_as/orderable_table.rb', line 11 def acts_as_orderable_table( = {}) @ordinal_field = [:ordinal_field] || :ordinal @starts_from = [:starts_from] || 0 validates @ordinal_field, presence: true validate :check_ordinal_uniqueness before_validation :set_defaults class_eval do include ActiveRecord::ActsAs::OrderableTable::InstanceMethods end end |