Module: ActionView::Helpers::ActiveRecordHelper

Included in:
ScaffoldingSandbox
Defined in:
lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/generators/active_scaffold/active_scaffold_generator.rb

Instance Method Summary collapse

Instance Method Details

#all_associations(record) ⇒ Object



113
114
115
116
117
118
119
120
121
122
123
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/generators/active_scaffold/active_scaffold_generator.rb', line 113

def all_associations(record)
   @results =""
   puts record.class.reflect_on_all_associations.inspect
   record.class.reflect_on_all_associations.each do |a|
    puts a.inspect
    if a.macro == :belongs_to
      @results += "<p>#{a.klass}<br/><%=f.select #{a.klass}.find(:all).collect {|i| [ p.inspect, p.id ] }, { :include_blank => true }) %>"
    end
  end
  @results
end

#all_input_tags(record, record_name, options) ⇒ Object



102
103
104
105
106
107
108
109
110
111
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/generators/active_scaffold/active_scaffold_generator.rb', line 102

def all_input_tags(record, record_name, options)
  input_block = options[:input_block] || default_input_block
  skip_columns = ["created_at", "lock_version", "created_on", "updated_at", "updated_on"]
  @results = record.class.content_columns.collect do |column|
   unless skip_columns.detect{|c| c == column.name}   || column.name.last(3) == "id"
     input_block.call(record_name, column) 
   end
  end
  @results.join("")
end

#quote(value) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/generators/active_scaffold/active_scaffold_generator.rb', line 125

def quote(value)
  case value
    when NilClass                  then "NULL"
    when TrueClass                then "TRUE"
    when FalseClass                then "FALSE"
    when Float, Fixnum, Bignum    then value.to_s
    # BigDecimals need to be output in a non-normalized form and quoted.
    when BigDecimal                then value.to_s('F')
    else
      value.inspect
  end
end