Class: Alchemy::ContentEditor
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Alchemy::ContentEditor
- Defined in:
- app/decorators/alchemy/content_editor.rb
Instance Method Summary collapse
- #css_classes ⇒ Object
- #data_attributes ⇒ Object
- #form_field_id(essence_column = "ingredient") ⇒ Object
-
#form_field_name(essence_column = "ingredient") ⇒ Object
Returns a string to be passed to Rails form field tags to ensure we have same params layout everywhere.
-
#respond_to?(method_name) ⇒ Boolean
Fixes Rails partial renderer calling to_model on the object which reveals the delegated content instead of this decorator.
- #to_partial_path ⇒ Object
Instance Method Details
#css_classes ⇒ Object
11 12 13 14 15 16 |
# File 'app/decorators/alchemy/content_editor.rb', line 11 def css_classes [ "content_editor", essence_partial_name, ].compact end |
#data_attributes ⇒ Object
18 19 20 21 22 23 |
# File 'app/decorators/alchemy/content_editor.rb', line 18 def data_attributes { content_id: id, content_name: name, } end |
#form_field_id(essence_column = "ingredient") ⇒ Object
43 44 45 |
# File 'app/decorators/alchemy/content_editor.rb', line 43 def form_field_id(essence_column = "ingredient") "contents_#{id}_#{essence_column}" end |
#form_field_name(essence_column = "ingredient") ⇒ Object
Returns a string to be passed to Rails form field tags to ensure we have same params layout everywhere.
Example:
<%= text_field_tag content_editor.form_field_name, content_editor.ingredient %>
Options:
You can pass an Essence column_name. Default is ‘ingredient’
Example:
<%= text_field_tag content_editor.form_field_name(:link), content_editor.ingredient %>
39 40 41 |
# File 'app/decorators/alchemy/content_editor.rb', line 39 def form_field_name(essence_column = "ingredient") "contents[#{id}][#{essence_column}]" end |
#respond_to?(method_name) ⇒ Boolean
Fixes Rails partial renderer calling to_model on the object which reveals the delegated content instead of this decorator.
49 50 51 52 53 |
# File 'app/decorators/alchemy/content_editor.rb', line 49 def respond_to?(method_name) return false if method_name == :to_model super end |
#to_partial_path ⇒ Object
7 8 9 |
# File 'app/decorators/alchemy/content_editor.rb', line 7 def to_partial_path "alchemy/essences/#{essence_partial_name}_editor" end |