lib/scaffolding_extensions/model/active_record.rb
# Returns the list of fields to display on the scaffolded forms. Defaults
# to displaying all columns with the exception of primary key column, timestamp columns,
# count columns, and inheritance columns.  Also includes belongs_to associations, replacing
# the foriegn keys with the association itself.  Can be set with an instance variable.
Returns the list of fields to display on the scaffolded forms. Defaults
to displaying all columns with the exception of primary key column, timestamp columns,
count columns, and inheritance columns.  Also includes belongs_to associations, replacing
the foriegn keys with the association itself.  Can be set with an instance variable.
Returns the list of fields to display on the scaffolded forms . Defaults to displaying all columns with the exception of primary key column timestamp columns count columns and inheritance columns . Also includes belongs_to associations replacing the foriegn keys with the association itself . Can be set with an instance variable .
def scaffold_fields(action = :default)
    return @scaffold_fields if @scaffold_fields
    fields = columns.reject{|c| c.primary || c.name =~ /(\A(created|updated)_at|_count)\z/ || c.name == inheritance_column}.collect{|c| c.name}
    scaffold_all_associations.each do |reflection|
      next if reflection.macro != :belongs_to || reflection.options.include?(:polymorphic)
      fields.delete(reflection.foreign_key)
      fields.push(reflection.name.to_s)
    end
    @scaffold_fields = fields.sort.collect{|f| f.to_sym}
  end
def scaffold_fields ( action = :default ) return @scaffold_fields if @scaffold_fields fields = columns . reject { | c | c . primary || c . name =~ / ( \A (created|updated)_at|_count) \z / || c . name == inheritance_column } . collect { | c | c . name } scaffold_all_associations . each do | reflection | next if reflection . macro != :belongs_to || reflection . options . include? ( :polymorphic ) fields . delete ( reflection . foreign_key ) fields . push ( reflection . name . to_s ) end @scaffold_fields = fields . sort . collect { | f | f . to_sym } end
Returns the list of fields to display on the scaffolded forms.
Returns the list of fields to display on the scaffolded forms .
action