`
yearl
  • 浏览: 6665 次
  • 性别: Icon_minigender_1
  • 来自: 顺德
最近访客 更多访客>>
社区版块
存档分类
最新评论

acts_as_list

阅读更多

 

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

decrement_position ()

Decrease the position of this item without adjusting the rest of the list.

 

first? ()

Return true if this object is the first in the list.

 

higher_item ()

Return the next higher item in the list.

 

in_list? ()

Test if this record is in a list

 

increment_position ()

Increase the position of this item without adjusting the rest of the list.

 

insert_at (position = 1)

Insert the item at the given position (defaults to the top position of 1).

 

last? ()

Return true if this object is the last in the list.

 

lower_item ()

Return the next lower item in the list.

 

move_higher ()

Swap positions with the next higher item, if one exists.

 

move_lower ()

Swap positions with the next lower item, if one exists.

 

move_to_bottom ()

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_top ()

Move to the top of the list. If the item is already in the list, the items above it have their position adjusted accordingly.

 

remove_from_list ()

Removes the item from the list.

分享到:
评论

相关推荐

    acts_as_list.rar

    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插件.zip

    acts_as_list, 用于管理列表的ActiveRecord插件 ActsAsList描述这个 acts_as 扩展提供了对列表中的多个对象进行排序和重新排序的功能。 具有指定的类的类需要在映射的数据库表上定义为整数的position 列。 0.8.0升级...

    acts_as_authenticated

    "acts_as_authenticated" 是一个经典的Ruby on Rails插件,它为Rails应用提供了用户认证功能。在Rails框架中,用户认证通常涉及验证用户身份、管理会话以及处理登录和登出等操作。acts_as_authenticated插件简化了这...

    rails_admin_acts_as_list:rails_admin插件以对记录进行排序

    介绍插件,用于对记录进行排序(使用 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一样,但很安静

    acts_as_restful_list 就像acts_as_list 一样,但不必使用非标准方法调用(如insert_at)来弄乱您的代码,acts_as_restful_list 使管理列表变得简单。 您可以像更新其他任何内容一样更新 position 属性,其余的都...

    ruby on rails 相关lib

    ruby on rails 相关lib 其中包含:rspec flexmock acts_as_taggable-2.0.2 widgets acts_as_list classic_pagination

    actions_as_list:用于管理列表的ActiveRecord插件

    acts_as_list现在可以处理不同的位置整数(即,数字之间的间隔)。 higher_items方法的行为已发生变化。 现在,它返回的项的集合中的第一项是与参考项最接近的项,而集合中的最后一项与参考项(即列表中

    activeadmin_reorderable:将拖放重新排序添加到您的ActiveAdmin表中

    您不需要使用acts_as_list ,但是,如果不需要,请确保定义insert_at 。 安装 将gem 'activeadmin_reorderable'添加到Gemfile 将#= require activeadmin_reorderable添加到app/assets/javascripts/active_admin.js...

    active_scaffold_sortable:花式裤子ActiveScaffold的可拖放排序列表

    用于ActiveScaffold的拖放排序当前,此插件与Rails&gt; = 4.0和ActiveScaffold&gt; = 3.3 gem兼容。 将3.2.x用于rails 3.x版本。概述这个插件可以在活动支架页面上启用那些流畅...position integer第2步将acts_as_list添加到

    activeadmin-sortable

    acts_as_list end 蒙古族 class Page &lt; ActiveRecord :: Base include Mongoid :: Orderable orderable end 用法 将其添加到您的Gemfile gem 'activeadmin-sortable' 在active_admin.js中包含JavaScript //...

    Rails True Dynamic Portal-开源

    在“Rails True Dynamic Portal”项目中,开发者可能会使用如acts_as_list或positioned_scope这样的gem来管理portlet的排序和位置,使用nested_form来处理复杂的表单布局,以及使用active_model_serializers来优化...

    Ruby-ActsAsTaggableOnRails应用程序标签插件允许自定义标签在动态环境中

    在实际项目中, ActsAsTaggableOn 的源代码库(如 `mbleigh-acts-as-taggable-on-4d9a10c`)包含了详细的实现细节,包括测试用例、文档和示例。你可以通过阅读源代码了解其内部工作原理,以及如何根据项目需求进行...

    Serial ATA AHCI 1.1 Specification.pdf

    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. ...

    trakt-scraper:一个Powershell脚本,可通过trakt来管理您的媒体收藏,并带有种子抓取和碎片支持

    铲运机 一个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

    VB编程资源大全(英文源码 控件)

    Please read Readme.txt&lt;END&gt;&lt;br&gt;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.&lt;END&gt;&lt;br&gt;27 , WCodeDll.zip COOL Small DLL...

    RemObjects SDK for Delphi

    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 ...

    range-free localization beyond connectivity

    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 ...

    a project model for the FreeBSD Project.7z

    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 ...

    newspaper-crawler-scripts:爬网报纸网站的脚本集

    报纸爬虫脚本 爬行报纸网站的脚本集。 请在下面找到可用的脚本 ... acts as a index for other directories. articles -- 2018 ---- Dec ---- May -- 2017 ---- Jun ---- Aug -- 2016 ---- Oct ---- Jan abs

    polycom宝利通视频会议软件3.9 2018

    (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....

Global site tag (gtag.js) - Google Analytics