Class: EasyAdmin::Types::JsonType
- Inherits:
-
ActiveRecord::Type::Json
- Object
- ActiveRecord::Type::Json
- EasyAdmin::Types::JsonType
- Defined in:
- lib/easy_admin/types/json_type.rb
Instance Method Summary collapse
- #cast(value) ⇒ Object
-
#type ⇒ Object
Inherit from Rails’ native JSON type for better compatibility.
Instance Method Details
#cast(value) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/easy_admin/types/json_type.rb', line 9 def cast(value) case value when String # Handle JSON strings from form inputs begin JSON.parse(value) rescue JSON::ParserError value # Return original string if not valid JSON end else # Let Rails handle other types super end end |
#type ⇒ Object
Inherit from Rails’ native JSON type for better compatibility
5 6 7 |
# File 'lib/easy_admin/types/json_type.rb', line 5 def type :json end |