Class: ActiveScaffold::Config::BatchCreate

Inherits:
Form
  • Object
show all
Defined in:
lib/active_scaffold/config/batch_create.rb

Constant Summary collapse

ActiveScaffold::DataStructures::ActionLink.new('batch_new', :label => :create, :type => :collection, :security_method => :batch_create_authorized?, :ignore_method => :batch_create_ignore?)
@@plugin_directory =
File.expand_path(__FILE__).match(%{(^.*)/lib/active_scaffold/config/batch_create.rb})[1]
@@process_mode =
:create
@@list_mode_enabled =
true
@@run_in_transaction =
true
@@layout =
:vertical

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ BatchCreate

Returns a new instance of BatchCreate.



4
5
6
7
8
9
10
11
# File 'lib/active_scaffold/config/batch_create.rb', line 4

def initialize(*args)
  super
  @multipart = @core.create.multipart? if @core.actions.include? :create
  @process_mode = self.class.process_mode
  @list_mode_enabled = self.class.list_mode_enabled
  @run_in_transaction = self.class.run_in_transaction
  @layout = self.class.layout
end

Instance Attribute Details

#default_batch_by_columnObject

you may use create_batch to create a record for each record of a belong_to association (reverse must be has_many) eg. player belongs to team you may batch create a player records for a list of teams



60
61
62
# File 'lib/active_scaffold/config/batch_create.rb', line 60

def default_batch_by_column
  @default_batch_by_column
end

#layoutObject

layout for create multiple records



67
68
69
# File 'lib/active_scaffold/config/batch_create.rb', line 67

def layout
  @layout
end

#list_mode_enabledObject

Returns the value of attribute list_mode_enabled.



54
55
56
# File 'lib/active_scaffold/config/batch_create.rb', line 54

def list_mode_enabled
  @list_mode_enabled
end

#process_modeObject

see class accessor



52
53
54
# File 'lib/active_scaffold/config/batch_create.rb', line 52

def process_mode
  @process_mode
end

#run_in_transactionObject

run all create statements in a transaction, so no record is created if someone fails



64
65
66
# File 'lib/active_scaffold/config/batch_create.rb', line 64

def run_in_transaction
  @run_in_transaction
end

Class Method Details

global level configuration


the ActionLink for this action



16
17
18
# File 'lib/active_scaffold/config/batch_create.rb', line 16

def self.link
  @@link
end

.link=(val) ⇒ Object



19
20
21
# File 'lib/active_scaffold/config/batch_create.rb', line 19

def self.link=(val)
  @@link = val
end

Instance Method Details

#action_groupObject



69
70
71
# File 'lib/active_scaffold/config/batch_create.rb', line 69

def action_group
  @action_group || (default_batch_by_column ? 'collection.batch' : 'collection')
end

#label(model = nil) ⇒ Object

the label= method already exists in the Form base class



74
75
76
77
# File 'lib/active_scaffold/config/batch_create.rb', line 74

def label(model = nil)
  model ||= @core.label(:count => 2)
  @label ? as_(@label) : as_(:create_model, :model => model)
end