Sha256: 10d0afe10110d9e19eb9633fb3017bcfaa5471198e0e3bb39d72a0b5eaa6ea6b
Contents?: true
Size: 1.44 KB
Versions: 3
Compression:
Stored size: 1.44 KB
Contents
# encoding: utf-8 module Freeberry class Utils class << self def parameterize_filename(filename) extension = File.extname(filename) basename = filename.gsub(/#{extension}$/, "") [basename.parameterize('_'), extension].join.downcase end def form_field(form_name, field_name, column, options={}) field = case column.type when :string, :binary, :integer, :float, :decimal then options[:class] = "'text'" "text_field" when :boolean then "check_box" when :datetime, :date, :timestamp, :time then options[:extra_html] ||= "<script type='text/javascript'> $(function() { $('\##{form_name}_#{field_name}').datepicker({ numberOfMonths: 1, dateFormat: 'dd.mm.yy' }); }); </script>" 'text_field' when :text then options[:cols] ||= 70 options[:rows] ||= 5 "text_area" end extra_html = options.delete(:extra_html) || '' options_fields = [] options.each { |k, v| options_fields << ":#{k}=>#{v}" } options_str = ", {#{options_fields.join(', ')}}" unless options_fields.empty? options_str ||= '' "<%= #{form_name}.#{field} #{field_name}#{options_str} %>#{extra_html}" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
freeberry-0.3.0 | lib/freeberry/utils.rb |
freeberry-0.2.9 | lib/freeberry/utils.rb |
freeberry-0.2.7 | lib/freeberry/utils.rb |