Class: ScaffoldingSandbox

Inherits:
Object show all
Includes:
ActionView::Helpers::ActiveRecordHelper
Defined in:
lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/generators/active_scaffold/active_scaffold_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ActionView::Helpers::ActiveRecordHelper

#all_associations, #all_input_tags, #quote

Instance Attribute Details

#form_actionObject

Returns the value of attribute form_action.



11
12
13
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/generators/active_scaffold/active_scaffold_generator.rb', line 11

def form_action
  @form_action
end

#model_instanceObject

Returns the value of attribute model_instance.



11
12
13
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/generators/active_scaffold/active_scaffold_generator.rb', line 11

def model_instance
  @model_instance
end

#singular_nameObject

Returns the value of attribute singular_name.



11
12
13
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/generators/active_scaffold/active_scaffold_generator.rb', line 11

def singular_name
  @singular_name
end

#suffixObject

Returns the value of attribute suffix.



11
12
13
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/generators/active_scaffold/active_scaffold_generator.rb', line 11

def suffix
  @suffix
end

Instance Method Details

#all_columns(record, record_name, options) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/generators/active_scaffold/active_scaffold_generator.rb', line 74

def all_columns(record, record_name, options) 
  join_str = "\n"
  if options[:as_columns]
    join_str = ', '
    input_block = options[:input_block] || default_as_block
  elsif options[:sa_columns]
    input_block = options[:input_block] || default_sa_block
  elsif options[:show_columns]
    input_block = options[:input_block] || default_show_block
  else
    input_block = options[:input_block] || default_input_block
  end

  if !options[:exclude].blank?
    filtered_content_columns = record.class.columns.reject { |column| options[:exclude].include?(column.name) }
  elsif options[:sa_columns]
    filtered_content_columns = record.class.columns.reject { |column| [:id, :created_at, :updated_at, :lock_version].include?(column.name.to_sym) or (column.name.include?('_id') and column.name.last(3) == '_id') }
  else
    filtered_content_columns = record.class.columns
  end

  filtered_content_columns.collect{ |column| input_block.call(record_name, column) }.sort.join(join_str)
end

#default_as_blockObject



51
52
53
54
55
56
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/generators/active_scaffold/active_scaffold_generator.rb', line 51

def default_as_block
  Proc.new { |record, column| 
    column_name = column.name
    column_name = column_name[0..-4] if column_name[-3, 3] == "_id"
":#{column_name}" }
end

#default_column_blockObject



42
43
44
45
46
47
48
49
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/generators/active_scaffold/active_scaffold_generator.rb', line 42

def default_column_block
  Proc.new { |record, column| 
    column_name = column.name
    column_name = column_name[0..-4] if column_name[-3, 3] == "_id"
"       [:#{column_name} => {
      :exclude => [:field_search, :list]
    }]," }
end

#default_input_blockObject

def default_input_block

Proc.new { |record, column| "<p><label for=\"#{record}_#{column.name}\">#{column.human_name}</label><br/>\n#{input(record, column.name)}</p>\n" }

end



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/generators/active_scaffold/active_scaffold_generator.rb', line 21

def default_input_block
  input_block = Proc.new { |record, column| "
    <li class=\"form-element <%= 'required' if active_scaffold_config.columns[:#{column.name}].required? %>\">
      <dl>
        <dt>
          <label for=\"record_#{column.name}\"><%= active_scaffold_config.columns[:#{column.name}].label %></label>
        </dt>
        <dd>
          <%= active_scaffold_input_for active_scaffold_config.columns[:#{column.name}] %>
            <span class=\"description\"><%= active_scaffold_config.columns[:#{column.name}].description %></span>
        </dd>
      </dl>
    </li>"}
end

#default_sa_blockObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/generators/active_scaffold/active_scaffold_generator.rb', line 58

def default_sa_block
  Proc.new { |record, column| 
    attrs = []
    attrs << "default(#{quote(column.default)})" if column.default
    attrs << "not null" unless column.null
    attrs << "primary key" if column.name == @model_instance.class.primary_key

    col_type = column.type.to_s
    if col_type == "decimal"
      col_type << "(#{column.precision}, #{column.scale})"
    else
      col_type << "(#{column.limit})" if column.limit
    end
"  attribute :#{column.name}, :is => :required"}
end

#default_show_blockObject



36
37
38
39
40
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/generators/active_scaffold/active_scaffold_generator.rb', line 36

def default_show_block
  input_block = Proc.new { |record, column| "
        <dt><%= active_scaffold_config.columns[:#{column.name}].label -%></dt>
        <dd><%= get_column_value(@record, active_scaffold_config.columns[:#{column.name}]) -%> &nbsp;</dd>"}
end

#sandbox_bindingObject



13
14
15
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/generators/active_scaffold/active_scaffold_generator.rb', line 13

def sandbox_binding
  binding
end