-
Notifications
You must be signed in to change notification settings - Fork 329
API: Create
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
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 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 ApiActionLink 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. 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).
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.
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