def delete_table_field
redirect_to :action => :list_table_fields, :table => @table
return true unless request.post?
field = params[:field].to_sym
if @model.extra_listable_attributes.select { |attr|
attr.name.to_sym == field }.empty?
flash[:error] << _('Attempting to remove invalid field: %s') % field
return false
end
begin
@model.connection.remove_column(@table, field)
flash[:notice] << _('Successfully removed field %s') % field
rescue Exception => err
flash[:error] << _('Error removing specified field: %s') % err
end
if field.to_s =~ /^(.*)_id$/ and
@model.connection.catalogs.include?($1.pluralize)
flash[:warning] << _('Please note we have _not_ dropped the ' +
'corresponding catalog for this column, ' +
'<em>%s</em>, to avoid data loss. You can manually ' +
'remove it.') % $1.pluralize
end
end