Skip to content
lukemelia edited this page Sep 14, 2010 · 19 revisions

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

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.

edit_after_create global local

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.

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 .rubyonrails.org/classes/ActiveRecord/Callbacks.html 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