Skip to content
activescaffold edited this page Sep 15, 2010 · 19 revisions

action_after_create global local v2.3+

An action which should be displayed after create a record. If nil, then after a successful create update form will be closed or redirected to index. Default is nil.

columns local

The set of columns used for the Create action. The columns themselves are not editable here – only their presence in the Create 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 Create form supports column grouping. 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.create.columns = [:username, :password]
config.create.columns.add_subgroup "Name" do |name_group|
  name_group.add :first_name, :middle_name, :last_name
end

edit_after_create global local until v2.2

A flag for whether the update form should be shown after create a record or not. If true, then after a successful create update form will be open. Default is false.

Since v2.3 is replaced with action_after_create

formats

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

Examples:

# Add a format
config.create.formats << :pdf

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 Create action to the List table. Most likely, you’ll use this to change the label for your link.

config.create.link.label = "Add a new 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. File uploads in ActiveScaffold are still a do-it-yourself project, but this flag makes it easier.

NOTE: file uploads do not work over AJAX, so multipart = true will only be effective when the form operates in a normal fashion (when it’s loaded as a new page, not inline).

persistent global local

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

before_create_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_create_save(record)
    record.created_by = current_user
  end
end

after_create_save [controller method]

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

Clone this wiki locally