Class: Alchemy::Ingredients::Datetime
- Inherits:
-
Alchemy::Ingredient
- Object
- ActiveRecord::Base
- BaseRecord
- Alchemy::Ingredient
- Alchemy::Ingredients::Datetime
- Defined in:
- app/models/alchemy/ingredients/datetime.rb
Overview
A datetime value
Instance Method Summary collapse
-
#preview_text(_maxlength = nil) ⇒ Object
Returns localized date for the Element#preview_text method.
- #value ⇒ Object
Methods inherited from Alchemy::Ingredient
#definition, #deprecated?, #essence, #has_hint?, #has_tinymce?, #has_validations?, normalize_type, #partial_name, #preview_ingredient?, related_object_alias, #settings, #settings_value, #to_partial_path, translated_label_for
Methods included from Hints
Instance Method Details
#preview_text(_maxlength = nil) ⇒ Object
Returns localized date for the Element#preview_text method.
13 14 15 16 17 |
# File 'app/models/alchemy/ingredients/datetime.rb', line 13 def preview_text(_maxlength = nil) return "" unless value ::I18n.l(value, format: :'alchemy.essence_date') end |
#value ⇒ Object
8 9 10 |
# File 'app/models/alchemy/ingredients/datetime.rb', line 8 def value ActiveRecord::Type::DateTime.new.cast(self[:value]) end |