Module: Trestle::FlashHelper
- Included in:
- Controller::Helpers
- Defined in:
- app/helpers/trestle/flash_helper.rb
Instance Method Summary collapse
- #debug_form_errors? ⇒ Boolean
- #instance_has_errors? ⇒ Boolean
- #normalize_flash_alert(flash) ⇒ Object
- #turbo_stream_update_flash ⇒ Object
Instance Method Details
#debug_form_errors? ⇒ Boolean
7 8 9 |
# File 'app/helpers/trestle/flash_helper.rb', line 7 def debug_form_errors? Trestle.config.debug_form_errors && instance_has_errors? end |
#instance_has_errors? ⇒ Boolean
11 12 13 |
# File 'app/helpers/trestle/flash_helper.rb', line 11 def instance_has_errors? instance.errors.any? rescue false end |
#normalize_flash_alert(flash) ⇒ Object
3 4 5 |
# File 'app/helpers/trestle/flash_helper.rb', line 3 def normalize_flash_alert(flash) flash.is_a?(Hash) ? flash.with_indifferent_access : { message: flash } end |
#turbo_stream_update_flash ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'app/helpers/trestle/flash_helper.rb', line 15 def turbo_stream_update_flash <<-EOF <turbo-stream action="update" target="flash"> <template> #{render_to_string(partial: "trestle/flash/flash", formats: [:html])} </template> </turbo-stream> EOF end |