Module: Galakei::SessionIdParameter::InForm

Defined in:
lib/galakei/session_id_parameter/in_form.rb

Overview

When making a get request from a form, query string parameters are ignored. Instead, the parameters must be added as hidden fields. This module ensures that the session id parameter is properly injected into forms.

Instance Method Summary collapse

Instance Method Details

#button_to(name, options = {}, html_options = {}) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/galakei/session_id_parameter/in_form.rb', line 11

def button_to(name, options = {}, html_options = {})
  return super unless html_options[:method] == :get
  url = (options.is_a?(String) ? options : url_for(options))
  session_id = extract_session_id!(url)
  return super if session_id.blank?
  s = super(name, url, html_options)
  s.sub("</form>", session_input_tag(session_id) + "</form>".html_safe).html_safe
end

#extra_tags_for_form(html_options) ⇒ Object

:nodoc:



5
6
7
8
9
# File 'lib/galakei/session_id_parameter/in_form.rb', line 5

def extra_tags_for_form(html_options)
  return super unless html_options["method"] == :get
  session_id = extract_session_id!(html_options["action"])
  session_id.blank? ? super : (super + session_input_tag(session_id)).html_safe
end