-
Notifications
You must be signed in to change notification settings - Fork 330
API: Update
Set this property so link is included in a group of links.
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`.
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
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.
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]
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.
The heading used for the Create action interface. Normally this heading is based on the core’s label.
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.
A flag for whether the form should be multipart or not. This is typically used to support file uploads.
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.
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.
Enable this property to refresh list after successful update when form is sent with AJAX.
ActiveScaffold doesn’t display unauthorized columns in forms. Enabling this property they will be displayed.
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
Similar to the above, but after your record is updated/saved.
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.