# -*- encoding : utf-8 -*- InlineForms::SPECIAL_COLUMN_TYPES[:kansen_slider]=:integer # kansen_slider def kansen_slider_show(object, attribute) values = attribute_values(object, attribute) value = object.send(attribute).to_i # should be an int display_value = values.assoc(value)[1] # values should be [ [ 0, value ], [ 3, value2 ] .... ] and we lookup the key, not the place in the array! css_id = "#{object.class.to_s.underscore}_#{object.id}_#{attribute}" if value == 0 || value > 5 out = display_value else out = "
".html_safe out << "
#{display_value}
".html_safe out << "
".html_safe out << "".html_safe out << ('').html_safe out << "
".html_safe end link_to_inline_edit object, attribute, out end def kansen_slider_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) value = object.send(attribute).to_i # should be an int, will be 0 if nil css_id = "#{object.class.to_s.underscore}_#{object.id}_#{attribute}" display_value = values.assoc(value)[1] # values should be [ [ 0, value ], [ 3, value2 ] .... ] and we lookup the key, not the place in the array! out = "
".html_safe out << "
#{display_value}
".html_safe out << "
".html_safe out << "".html_safe out << ('').html_safe out << '
'.html_safe out end def kansen_slider_update(object, attribute) object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym] end # # # # #
# #

# # #

# #
# #
#