Module: Bh::Helpers::Confirmations

Included in:
Bh::Helpers
Defined in:
lib/bh/helpers/confirmations.rb

Overview

The button that asks before it acts.

Instance Method Summary collapse

Instance Method Details

#confirm_button_to(words, path, confirm:, **options) ⇒ String

A button whose form is sent only where the question it carries is answered yes. The bundle draws that question as a dialog. Every option is the button's, and the question rides on the form, which is what Turbo asks before submitting either.

Parameters:

  • words (String)

    what the button reads.

  • path (String)

    where the form is sent.

  • confirm (String)

    the question, its first line the title of the dialog.

  • options (Hash)

    anything else the button takes.

Returns:

  • (String)

    the form and the button in it.



13
14
15
16
17
# File 'lib/bh/helpers/confirmations.rb', line 13

def confirm_button_to(words, path, confirm:, **options)
  form = { data: { turbo_confirm: confirm } }.deep_merge options.fetch(:form, {})

  button_to words, path, **options.except(:form), form: form
end