Module
ActiveRecord::Acts::List::InstanceMethods |
|
http://api.rubyonrails.org/classes/ActiveRecord/Acts/List/InstanceMethods.html#M000686
<!-- banner header -->
All the methods available to a record that has had acts_as_list
specified. Each method works by assuming the object to be the item in the
list, so chapter.move_lower
would move that chapter lower in the
list of all chapters. Likewise, chapter.first?
would return true
if that chapter is the first in the list of all chapters.
Example
=======
class TodoList < ActiveRecord::Base
has_many :todo_items, :order => "position"
end
class TodoItem < ActiveRecord::Base
belongs_to :todo_list
acts_as_list :scope => :todo_list
end
todo_list.first.move_to_bottom
todo_list.last.move_higher
Methods
Public Instance methods
Decrease the position of this item without adjusting the rest of the list.
Return true if this object is the first in the list.
Return the next higher item in the list.
Test if this record is in a list
Increase the position of this item without adjusting the rest of the list.
Insert the item at the given position (defaults to the top position of 1).
Return true if this object is the last in the list.
Return the next lower item in the list.
Swap positions with the next higher item, if one exists.
Swap positions with the next lower item, if one exists.
Move to the bottom of the list. If the item is already in the list, the
items below it have their position adjusted accordingly.
Move to the top of the list. If the item is already in the list, the items
above it have their position adjusted accordingly.
Removes the item from the list.
分享到:
相关推荐
acts_as_list.raracts_as_list.raracts_as_list.raracts_as_list.raracts_as_list.raracts_as_list.raracts_as_list.raracts_as_list.raracts_as_list.raracts_as_list.raracts_as_list.raracts_as_list.raracts_as_...
acts_as_list, 用于管理列表的ActiveRecord插件 ActsAsList描述这个 acts_as 扩展提供了对列表中的多个对象进行排序和重新排序的功能。 具有指定的类的类需要在映射的数据库表上定义为整数的position 列。 0.8.0升级...
"acts_as_authenticated" 是一个经典的Ruby on Rails插件,它为Rails应用提供了用户认证功能。在Rails框架中,用户认证通常涉及验证用户身份、管理会话以及处理登录和登出等操作。acts_as_authenticated插件简化了这...
介绍插件,用于对记录进行排序(使用 gem)安装要启用rails_admin_acts_as_list,请将以下内容添加到您的Gemfile : gem 'rails_admin_acts_as_list'gem 'rails_admin' 重要提示: rails_admin_acts_as_list之前必须...
acts_as_restful_list 就像acts_as_list 一样,但不必使用非标准方法调用(如insert_at)来弄乱您的代码,acts_as_restful_list 使管理列表变得简单。 您可以像更新其他任何内容一样更新 position 属性,其余的都...
ruby on rails 相关lib 其中包含:rspec flexmock acts_as_taggable-2.0.2 widgets acts_as_list classic_pagination
acts_as_list现在可以处理不同的位置整数(即,数字之间的间隔)。 higher_items方法的行为已发生变化。 现在,它返回的项的集合中的第一项是与参考项最接近的项,而集合中的最后一项与参考项(即列表中
您不需要使用acts_as_list ,但是,如果不需要,请确保定义insert_at 。 安装 将gem 'activeadmin_reorderable'添加到Gemfile 将#= require activeadmin_reorderable添加到app/assets/javascripts/active_admin.js...
用于ActiveScaffold的拖放排序当前,此插件与Rails> = 4.0和ActiveScaffold> = 3.3 gem兼容。 将3.2.x用于rails 3.x版本。概述这个插件可以在活动支架页面上启用那些流畅...position integer第2步将acts_as_list添加到
acts_as_list end 蒙古族 class Page < ActiveRecord :: Base include Mongoid :: Orderable orderable end 用法 将其添加到您的Gemfile gem 'activeadmin-sortable' 在active_admin.js中包含JavaScript //...
在“Rails True Dynamic Portal”项目中,开发者可能会使用如acts_as_list或positioned_scope这样的gem来管理portlet的排序和位置,使用nested_form来处理复杂的表单布局,以及使用active_model_serializers来优化...
在实际项目中, ActsAsTaggableOn 的源代码库(如 `mbleigh-acts-as-taggable-on-4d9a10c`)包含了详细的实现细节,包括测试用例、文档和示例。你可以通过阅读源代码了解其内部工作原理,以及如何根据项目需求进行...
AHCI is a PCI class device that acts as a data movement engine between system memory and Serial ATA devices. AHCI host devices (referred to as host bus adapters, or HBA) support from 1 to 32 ports. ...
铲运机 一个Powershell脚本,可通过... - Your watchlist acts as a download queue for content you havent collected. 2. rarbg: - If new content is found, a scraper for rarbg.to searches for the best qualit
Please read Readme.txt<END><br>26 , LOVDLL.zip It will act as List Of Values. You might have seen List Of Values in Developer. It will act same as that.<END><br>27 , WCodeDll.zip COOL Small DLL...
Each instance of the application acts both as a server and as a client. For the server, you can modify the list of services supported on the right-hand side, while for the client you can enter a ...
It acts as a supporting layer that enhances the positioning accuracy without requiring significant additional overhead. #### Implementation and Evaluation To validate the effectiveness of the ...
The vision is “To produce the best UNIX-like operating system package possible, with due respect to the original software tools ideology as well as usability, performance and stability.” The ...
报纸爬虫脚本 爬行报纸网站的脚本集。 请在下面找到可用的脚本 ... acts as a index for other directories. articles -- 2018 ---- Dec ---- May -- 2017 ---- Jun ---- Aug -- 2016 ---- Oct ---- Jan abs
(if you are located in the rest of the world) (each referred to individually and collectively herein as “POLYCOM”), for the SOFTWARE PRODUCT (as defined below) licensed by POLYCOM or its suppliers....