Code Monkey home page Code Monkey logo

acts_as_positioned's Introduction

ActsAsPositioned

ActsAsPositioned is a featherweight gem for keeping records organized by position. We wrote it because keeping slideshow slides organized in RailsAdmin and Typus was frustrating. Stuff should just go where you put it.

ActsAsPositioned borrows much from ActsAsList, but does less and is more useful in today's Rails 3 universe.

Requirements

  1. You are using Rails 3.1 or higher.

Installation

Add this to your gemfile:

gem 'acts_as_positioned', :git => 'git://github.com/stager94/acts_as_positioned.git'

Run bundle install.

Run rails generate position MODEL

The generator creates a migration to add a position column of type integer to the specified model.

Run rake db:migrate

Usage

Call acts_as_positioned in your models.

Basic

class Slide < ActiveRecord::Base
  # this is the good bit:
  acts_as_positioned 

  # remember to order by position, either here or in your controllers.
  default_scope order(:position)
end

Scoped

If positions aren't unique -- suppose you're organizing 24 songs under 2 albums -- supply an :under option.

class Song < ActiveRecord::Base
  belongs_to :album  
  acts_as_positioned :under => :album
end

Questions?

Write to [email protected].

acts_as_positioned's People

Contributors

stager94 avatar hipsterelitist avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.