Created
November 15, 2008 19:01
-
-
Save rhyhann/25298 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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