Skip to content
This repository

Handles positioning (ordering) your ActiveRecord Objects.

branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time


Is Positionable

What is “Is Positionable”?

Is Positionable handles the positioning (ordering) your ActiveRecord Objects. It makes use of the “Acts As List” gem to do it the most efficient way. Is Positionable basically creates a front-end (dynamically generates buttons and actions) for moving ActiveRecord Objects “up”, “down”, to the “top” and to the “bottom”. Doing the simplest set up takes just 1 word: “is_positionable”.

Quick and Simple Example


config.gem "is_positionable", :source => ""


PostsController < ApplicationController

  def index
    @posts = Post.all


class Post < ActiveRecord::Base
  default_scope :order => :position


for post in @posts
  <%= up_button_for_posts(@posts, post) %>
  <%= down_button_for_posts(@posts, post) %>
  <%= top_button_for_posts(@posts, post) %>
  <%= bottom_button_for_posts(@posts, post) %>
  # Other Stuff like etc.

With just this bit of code, you now enabled positioning with “posts”. This might already be obvious, but the following 4 buttons are generated per post:

  • Up Button

  • Down Button

  • To Top Button

  • To Bottom Button

Now, this is the most basic setup. You might have “users” manage posts. So that'd mean “User has_many :posts”. In this case you can add a “scope” and “scope_object” so that one user cannot conflict with another user's post positions.

This would look something like this

is_listable :scope        => :user_id,
            :scope_object => current_user

# Assuming that "current_user" is the currently logged in use

The above will ensure that, not only will one users' post NOT conflict with another users' post, but if one user tries to be hack-ish and try to attempt to change post position of a different user through cURL or the AddressBar it will be out of scope cause of the :scope_object attribute, restricting access to any other user, but the owner of the post.

Of course, these are not the only options you can set, for more information, see the Wiki pages!

Setting all this up takes me about 1-2 minutes

Interested in trying out “Is Positionable”?

Check out the following Wiki pages:


Getting Started



Copyright © 2009 meskyanichi. See LICENSE for details.

Something went wrong with that request. Please try again.