Automatically increments the position field for an ActiveRecord model in a before_save
callback.
Add this line to your application's Gemfile:
gem 'simple_position'
Add an integer position
column to your model:
add_column :pages, :position, :integer
Include SimplePosition
class into your model:
class Page < ActiveRecord::Base
include SimplePosition
default_scope order(:position)
end
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request