API:动作链接

Action Links are used to tie pieces of ActiveScaffold together, and can be used to integrate your own functionality. They can be attached and configured in a variety of places. Native actions like Create, Update, and Delete have configurable links within their own config sections (e.g. config.create.link), and column objects may themselves have an action link (e.g. config.columns[:username].link). The main config.action_links collection is meant for your custom links.

动作链接是用来将零碎的ActiveScaffold联系在一起,也可以用来整合自己的功能。他们可以在很多地方被用来附加和配置。诸如创建、修改和删除等本地动作都在它们自己内部的配置区域(比如 config.create.link)有可配置的链接,而字段对象可能有它们自己的动作链接(比如 config.columns[:username].link)。主要的 config.action_links集合被用作你的自定义链接。

action(动作)

The :action value of the URL

:action的URL值

controller(控制器) v1.1

Lets you specify a different controller for the action link. In version 1.0 you had to sneak this in through the :parameters option.

让你给动作链接指定一个不同的控制器。在版本1.0的时候,你只能通过 :parameters 选项暗中达到这个目的。

parameters(参数)

Miscellaneous parameters for the URL. In version 1.0, if you want to link to another controller you need to specify a :controller parameter here.

URL的各色各样参数。在版本1.0的时候,如果你想要链接到另一个控制器,你需要在这里指定一个:controller参数

method(方法)

Specifies a method for RESTful links. Default is :get.

为RESTful链接指定一个方法。默认是 :get

Values: :get, :post, :put, :delete

type(类型)

Determines whether the link appears on each record, or just once for the entire scaffold.

决定链接是在每个记录上显示,还是在整个scaffold上只显示一次。

Values: :table, :record

label(标签)

The visible text for the link.

链接的可视内容。

confirm(确认)

The confirmation message for the link, if any.

链接的确认信息,如果有的话。

security_method(安全方法)

Specifies a method on the controller that determines whether to show this link or not. Note that this does NOT prevent someone from URL hacking.

在控制器上指定一个方法,来决定是否显示这个链接。

Values: a symbol naming the method (e.g. :logged_in?)

值: 方法的一个符号名字(比如 :logged_in?

crud_type

Specifies that the (eventual) CRUD action initiated by this link will be one of the core CRUD types. This is used to check authorization and disable the link.

指定被这个链接初始化的(最终的)CRUD动作将成为核心CRUD类型之一。这是用来检查授权和禁止链接。

Values: :create, :read, :update, :destroy

inline(内联)

When true, the link will open with an AJAX call, using the :position option.

当设置为true时,这个链接会以AJAX调用的方式打开,它使用了:position选项。

Values: true, false

page(页面)

When true, the link will open with standard HTML behavior.

当设置为true时,这个链接会以标准HTML的行为打开。

Values: true, false

popup(弹出)

When true, the link will open in a new window. Currently there is no configuration option to set the size of the new window.

当设置为true时,链接会打开一个新的窗口。目前还没有配置选项来设置新窗口的大小。

Values: true, false

position(位置)

For inline links, determines where the result goes. When set to false, then ActiveScaffold will not try to automatically place the result (good for RJS responses).

对于内联链接来说,这个设置决定结果在哪里显示。如果设置为false,那么ActiveScaffold将不尝试自动为结果确定位置(这点对于RJS响应很好)

值:

  • for :type => :table: :top, false.
  • for :type => :record: :replace, :after, :before, and false.

association.reverse(逆向关联)

For association columns, lets you specify the reverse association name in case ActiveScaffold is unable to guess itself. For more information see the Nested Scaffolds docs.

对于关联的字段,万一ActiveScaffold不能自己猜测,这个设置可以让你指定逆向关联的名字。您可以在嵌套脚手架(Nested Scaffold)文档中得到更多信息。