Skip to content
Sergio Cambra edited this page Oct 25, 2024 · 18 revisions

action_group global local

Set this property so link is included in a group of links.

add_locking_column global local

It’s enabled by default. When enabled, if the model uses optimistic locking (checked with `locking_enabled?`), then a hidden field for the locking column will be added automatically, no need to add it to `update.columns`.

columns local

The set of columns used for the Update action. The columns themselves are not editable here – only their presence in the Update form. Note that the form automatically excludes :created_on, :created_at, :updated_on, and :updated_at.

Columns not in this set will not be accepted as input. This is to prevent hackers from sneaking unexpected data into your models.

The Update form supports subgroups. To create a subgroup, call columns.add_subgroup and pass a name and a block. The name will be used to label the subgroup in the view, and the block will let you configure the column set like normal.

Example:

config.update.columns = [:username, :password]
config.update.columns.add_subgroup "Name" do |name_group|
  name_group.add :first_name, :middle_name, :last_name
end

floating_footer global local

A flag to enable floating footer, so buttons of form footer are floating when the form is too big to fit in the window, and they are always accessible without scrolling down.

formats

Active scaffold supports html, js, json, yaml, and xml formats by default. If you need to add another mime type for the update action you can do it here. The format is then added to the default formats.

Examples:

config.update.formats << :pdf
# or
config.update.formats = [:pdf]

hide_nested_column local

ActiveScaffold doesn’t display nested column in forms. Enable this property so when you edit a record from a nested scaffold parent column will be displayed.

label local

The heading used for the Create action interface. Normally this heading is based on the core’s label.

link global local

The action link used to tie the “update” action to the List table. Most likely, you’ll use this to change the label for your link.

config.update.link.label = "Edit User"

See API: Action Link for additional parameters for this link.

multipart local

A flag for whether the form should be multipart or not. This is typically used to support file uploads.

nested_links global local

A flag for whether nested links should be shown at page top or not. Only they will be shown when it’s update form is loaded in page, not in list over AJAX.

persistent global local 2.4+

A flag for whether the update form should be persistent or not. If persistent, then after a successful update it will stay open. Default is false.

Since 3.2.15 you can set persistent to :optional, and you will get “Update” and “Apply” buttons.

refresh_list global local

Enable this property to refresh list after successful update when form is sent with AJAX.

show_unauthorized_columns global local

ActiveScaffold doesn’t display unauthorized columns in forms. Enabling this property they will be displayed.

Controller Methods

before_update_save [controller method]

If you want to add or tweak some data before the record gets saved, define this method on your controller. But first, be sure you don’t want to define a callback on your ActiveRecord model instead! This controller method is most useful for adding session-specific data to your model, like the current user.

Example:

class TaskController < ApplicationController
  active_scaffold :tasks

  protected

  def before_update_save(record)
    record.updated_by = current_user
  end
end

after_update_save [controller method]

Similar to the above, but after your record is updated/saved.

on_stale_object_error [controller method]

Called when StaleObjectError is raised. The exception is rescued, and a error message is added to the record, the message uses the translation key version_inconsistency under the active_scaffold scope.

Clone this wiki locally