Sha256: 9e2ea1c08fc0fb302926d80cc814e56330d4355ac535307d6045825af8aa4010
Contents?: true
Size: 981 Bytes
Versions: 255
Compression:
Stored size: 981 Bytes
Contents
# -*- encoding : utf-8 -*- InlineForms::SPECIAL_COLUMN_TYPES[:scale_with_values]=:integer # scale_with_values generates a scale # with the given list of values as options # # values must be a hash { integer => string, ... } or an one-dimensional array of strings def scale_with_values_show(object, attribute) values = attribute_values(object, attribute) link_to_inline_edit object, attribute, values[object.send(attribute)][1] end def scale_with_values_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_values_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