Skip to content

Instantly share code, notes, and snippets.

@rhyhann
Created November 15, 2008 19:01
Show Gist options
  • Save rhyhann/25298 to your computer and use it in GitHub Desktop.
Save rhyhann/25298 to your computer and use it in GitHub Desktop.
module Merb
module FlansHelper
def sexify(model)
model.class.properties.each do |p|
t = ::DataMapper::Types
result = ''
case p.type
when t::Boolean, TrueClass
result += label :"#{p.name}"
result += check_box :"#{p.name}"
when String, Float, Fixnum, Integer, BigDecimal
puts (label :"#{p.name}")
result += text_field :"#{p.name}"
when t::Text
result += label :"#{p.name}"
result += text_area :"#{p.name}"
when Date
result += tag :label, :class => :date do
yearc = (Time.now.year-100..Time.now.year)
select :"#{p.name}_month", :collection => (1..12).to_a; puts " / "
select :"#{p.name}_day" , :collection => (1..31).to_a; puts " / "
select :"#{p.name}_year" , :collection => (yearc).to_a; puts " / "
end
end
puts result
return result
end;end;end;end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment