New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

is_positionable

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is_positionable

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= 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/environment.rb

config.gem "is_positionable", :source => "http://gemcutter.org/"

==== app/controllers/posts_controller.rb

PostsController < ApplicationController is_positionable

def index
  @posts = Post.all
end
...

end

==== app/models/post.rb

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

==== app/views/posts/index.html.erb

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 post.name post.user.name etc. end

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:

=== Installation

http://wiki.github.com/meskyanichi/is_positionable/installation

=== Getting Started

http://wiki.github.com/meskyanichi/is_positionable/getting-started

=== Options

http://wiki.github.com/meskyanichi/is_positionable/options

== Copyright

Copyright (c) 2009 meskyanichi. See LICENSE for details.

FAQs

Package last updated on 05 Oct 2009

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc