Sha256: 9c79f1a32b45aa33246e1facb600c6793a3b869f8a7b14a07ee3b09a55d5e62a

Contents?: true

Size: 971 Bytes

Versions: 255

Compression:

Stored size: 971 Bytes

Contents

# -*- encoding : utf-8 -*-
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.underscore).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.underscore).to_sym][attribute.to_sym]
end

Version data entries

255 entries across 255 versions & 1 rubygems

Version Path
inline_forms-3.0.47 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.46 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.45 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.44 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.43 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.42 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.41 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.40 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.39 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.38 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.37 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.36 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.35 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.34 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.32 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.31 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.30 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.29 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.28 lib/app/helpers/form_elements/scale_with_integers.rb
inline_forms-3.0.27 lib/app/helpers/form_elements/scale_with_integers.rb