Module: TurboButton::Helper

Defined in:
lib/turbo_button/helper.rb

Instance Method Summary collapse

Instance Method Details

#turbo_button(text, action, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/turbo_button/helper.rb', line 3

def turbo_button(text, action, options = {})
  controller, action = action.split('#')
  url = url_for(controller: controller, action: action)

  button_to(text, url, {
    form: {
      data: {
        turbo_frame: options[:frame] || '_top'
      }
    },
    method: :post,
    params: options[:post] || {}
  })
end