Sha256: ed81f489595c174283a595dd63267b9aea29c96ecdda059be532f0aaf3671ba7

Contents?: true

Size: 940 Bytes

Versions: 12

Compression:

Stored size: 940 Bytes

Contents

InlineForms::SPECIAL_COLUMN_TYPES[:scale_with_integers]=:integer

# scale_with_integers generates a scale
# with the given list of integers as options
#
# values must be a Range or a one-dimensional array of Integers
#
def scale_with_integers_show(object, attribute)
  values = attribute_values(object, attribute)
  link_to_inline_edit object, attribute, values[object.send(attribute).to_s]
end

def scale_with_integers_edit(object, attribute)
  # the leading underscore is to avoid name conflicts, like 'email' and 'email_type' will result in 'email' and 'email[email_type_id]' in the form!
  values = attribute_values(object, attribute)
  collection_select( ('_' + object.class.to_s.downcase).to_sym, attribute.to_sym, values, 'first', 'last', :selected => object.send(attribute))
end

def scale_with_integers_update(object, attribute)
  object[attribute.to_sym] = params[('_' + object.class.to_s.downcase).to_sym][attribute.to_sym]
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
inline_forms-0.9.4 app/helpers/form_elements/scale_with_integers.rb
inline_forms-0.9.3 app/helpers/form_elements/scale_with_integers.rb
inline_forms-0.9.2 app/helpers/form_elements/scale_with_integers.rb
inline_forms-0.9.1 app/helpers/form_elements/scale_with_integers.rb
inline_forms-0.9.0 app/helpers/form_elements/scale_with_integers.rb
inline_forms-0.8.6 app/helpers/form_elements/scale_with_integers.rb
inline_forms-0.8.5 app/helpers/form_elements/scale_with_integers.rb
inline_forms-0.8.4 app/helpers/form_elements/scale_with_integers.rb
inline_forms-0.8.3 app/helpers/form_elements/scale_with_integers.rb
inline_forms-0.8.2 app/helpers/form_elements/scale_with_integers.rb
inline_forms-0.8.1 app/helpers/form_elements/scale_with_integers.rb
inline_forms-0.8.0 app/helpers/form_elements/scale_with_integers.rb