module ActsAsContactable # = Tag Helper to render different inputs depending on ContactField#field_type # # Example: <%= contact_field 'post',@post.contact_fields.first %> module ViewHelpers def contact_field(parent_type,field,value = nil, options = {}) tag_name = "#{parent_type}[contact_fields][#{field.name.to_normal}]" tag_id = "#{parent_type}_#{field.name.to_normal}" options = options.update( :id=>tag_id ) case field.field_type.to_sym when :text,:email,:int text_field_tag tag_name, value, options when :textarea text_area_tag tag_name, value, options when :password password_field_tag tag_name, value, options when :checkbox check_box_tag tag_name, 1, false, options end end end end