lib/scaffolding_extensions/meta_model.rb
# Filters the provided attributes to just the ones given by scaffold_attributes for
# the given action, and converts foreign key fields to integers so that autocompleting
# works correctly.
Filters the provided attributes to just the ones given by scaffold_attributes for
the given action, and converts foreign key fields to integers so that autocompleting
works correctly.
Filters the provided attributes to just the ones given by scaffold_attributes for the given action and converts foreign key fields to integers so that autocompleting works correctly .
def scaffold_filter_attributes(action, attributes)
      convert_attributes, allowed_attributes = scaffold_fields(action).partition{|x| scaffold_association(x)}.map{|x| x.map{|y| scaffold_field_id(y).to_s}}
      h = {}
      attributes.each do |k,v|
        if allowed_attributes.include?(k)
          h[k] = v
        elsif convert_attributes.include?(k)
          h[k] = v.to_s.strip.empty? ? '' : v.to_i.to_s
        end
      end
      h
    end
def scaffold_filter_attributes ( action , attributes ) convert_attributes , allowed_attributes = scaffold_fields ( action ) . partition { | x | scaffold_association ( x ) } . map { | x | x . map { | y | scaffold_field_id ( y ) . to_s } } h = { } attributes . each do | k , v | if allowed_attributes . include? ( k ) h [ k ] = v elsif convert_attributes . include? ( k ) h [ k ] = v . to_s . strip . empty? ? '' : v . to_i . to_s end end h end
Filters the provided attributes to just the ones given by scaffold_attributes for
the given action, and converts foreign key fields to integers so that autocompleting
works correctly.
Filters the provided attributes to just the ones given by scaffold_attributes for the given action and converts foreign key fields to integers so that autocompleting works correctly .
action
<not_specific>
attributes
<not_specific>