![38% of CISOs Fear They’re Not Moving Fast Enough on AI](https://cdn.sanity.io/images/cgdhsj6q/production/faa0bc28df98f791e11263f8239b34207f84b86f-1024x1024.webp?w=400&fit=max&auto=format)
Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
= sortable
Allows you to sort ActiveRecord items similar to http://github.com/rails/acts_as_list but with added support for multiple scopes and lists
Requires ActiveRecord >= 2.0.0
== Installation
gem install shuber-sortable --source http://gems.github.com OR script/plugin install git://github.com/shuber/sortable.git
== Examples
=== Simple
Works just like http://github.com/rails/acts_as_list
class Todo < ActiveRecord::Base # schema # id :integer # project_id :integer # description :string # position :integer sortable :scope => :project_id end
@todo = Todo.create(:description => 'do something', :project_id => 1) @todo_2 = Todo.create(:description => 'do something else', :project_id => 1) @todo_3 = Todo.create(:description => 'some other task', :project_id => 2)
@todo.position # 1 @todo_2.position # 2 @todo_3.position # 1
@todo.move_down! @todo_2.reload
@todo.position # 2 @todo_2.position # 1 @todo_3.position # 1
=== Multiple scopes
Stories may or may not be in a sprint, but if we scoped just by :sprint_id, all stories with a nil :sprint_id would be sorted in one giant list instead of being sorted in each of their respective projects. Specifying an array of scopes fixes this problem.
class Story < ActiveRecord::Base # schema # id :integer # project_id :integer # sprint_id :integer # description :string # position :integer sortable :scope => [:project_id, :sprint_id] end
=== Multiple lists
Your project management software needs to allow both clients and developers to prioritize todo items separately so that they can be discussed and reviewed during their next meeting. Multiple lists solves this problem.
class Todo < ActiveRecord::Base # schema # id :integer # project_id :integer # description :string # client_priority :integer # developer_priority :integer sortable :scope => :project_id, :column => :client_priority, :list_name => :client sortable :scope => :project_id, :column => :developer_priority, :list_name => :developer end
@todo = Todo.create(:description => 'do something', :project_id => 1) @todo_2 = Todo.create(:description => 'do something else', :project_id => 1)
@todo.client_priority # 1 @todo.developer_priority # 1 @todo_2.client_priority # 2 @todo_2.developer_priority # 2
@todo.move_down!(:client) @todo_2.reload
@todo.client_priority # 2 @todo.developer_priority # 1 @todo_2.client_priority # 1 @todo_2.developer_priority # 2
=== Switching scope
Any attributes specified as a :scope that are changed on an item cause the item to automatically switch lists when it is saved
class Todo < ActiveRecord::Base # schema # id :integer # project_id :integer # description :string # position :integer sortable :scope => :project_id end
@todo = Todo.create(:description => 'do something', :project_id => 1) @todo_2 = Todo.create(:description => 'do something else', :project_id => 1)
@todo.position # 1 @todo_2.position # 2
@todo.project_id = 2 @todo.save @todo_2.reload
@todo.position # 1 @todo_2.position # 1
== Instance methods
add_to_list!(list_name = nil)
first_item(list_name = nil)
first_item?(list_name = nil)
higher_items(list_name = nil)
in_list?(list_name = nil)
insert_at!(position = 1, list_name = nil)
item_at_offset(offset, list_name = nil)
last_item(list_name = nil)
last_item?(list_name = nil)
last_position(list_name = nil)
lower_items(list_name = nil)
move_down!(list_name = nil)
move_up!(list_name = nil)
move_to_bottom!(list_name = nil)
move_to_top!(list_name = nil)
next_item(list_name = nil)
previous_item(list_name = nil)
remove_from_list!(list_name = nil)
sortable_scope_changed?
sortable_scope_changes
== Contact
Problems, comments, and suggestions all welcome: shuber@huberry.com
FAQs
Unknown package
We found that shuber-sortable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.