Skip to content

Instantly share code, notes, and snippets.

@nauman
Created September 11, 2013 01:40
Show Gist options
  • Save nauman/6518355 to your computer and use it in GitHub Desktop.
Save nauman/6518355 to your computer and use it in GitHub Desktop.
module Basefields
def default_fields label
case label
when "name" then "text_field"
when "password" then "password_field"
when "hidden" then "hidden_field"
when "message" , "description" then "text_area"
#when "position" then "number_field"
when "email" then "email_field"
else sql_type_fields label
end
end
def sql_type_fields label
label_type = self.class.column_types[label].type
case label_type
when :integer then "number_field"
when :text then "text_area"
when :string then "text_field"
when :boolean then "check_box"
else "text_field"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment