Class: Wf::Field
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Wf::Field
- Defined in:
- app/models/wf/field.rb
Instance Method Summary collapse
- #array? ⇒ Boolean
-
#field_type_for_view ⇒ Object
TODO: array type.
- #type_for_cast ⇒ Object
Instance Method Details
#array? ⇒ Boolean
63 64 65 |
# File 'app/models/wf/field.rb', line 63 def array? field_type.to_s.match(/^(\w+)(\[\])?$/)[2] == "[]" end |
#field_type_for_view ⇒ Object
TODO: array type
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/models/wf/field.rb', line 44 def field_type_for_view case field_type when "string" "text_field" when "integer" "number_field" when "date" "date_field" when "datetime" "datetime_field" when "boolean" "check_box" when "text" "text_area" else "text_field" end end |
#type_for_cast ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'app/models/wf/field.rb', line 67 def type_for_cast type = field_type.to_s.match(/^(\w+)(\[\])?$/)[1] if array? ActiveRecord::Type.lookup(type.to_sym, adapter: :postgresql, array: true) else ActiveRecord::Type.lookup(type.to_sym, adapter: :postgresql) end end |