https://github.com/johnvuko/acts_as_sortable
https://github.com/johnvuko/acts_as_sortable
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/johnvuko/acts_as_sortable
- Owner: johnvuko
- Created: 2012-07-11T13:36:08.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2012-12-09T04:04:29.000Z (over 13 years ago)
- Last Synced: 2025-02-28T23:46:50.930Z (over 1 year ago)
- Language: Ruby
- Size: 109 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
ActsAsSortable
======================
A plugin to sort ActiveRecord model.
Installation
------------
Include the gem in your Gemfile:
gem 'acts_as_sortable', :git => 'https://github.com/jonathantribouharet/acts_as_sortable'
Usage
-----
In your migrations:
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.position
end
end
end
Minimal configuration in your model:
class User < ActiveRecord::Base
acts_as_sortable
end
Custom configuration in your model:
class User < ActiveRecord::Base
acts_as_sortable do |config|
config.acts_as_sortable_scope = :category_id
end
end
* `acts_as_sortable_scope` is the scope for sort, by default it's nil.
Each instance have two methods :
`position_up!` to upper element in order
`position_down!` to lower element in order