Module: HoneyPotEngine::FormInjector

Defined in:
lib/honey_pot_engine/form_injector.rb

Instance Method Summary collapse

Instance Method Details

#form_for(record, options = {}, &block) ⇒ Object

Railsのform_forにも同様の拡張を適用(レガシー対応用)



12
13
14
15
16
17
# File 'lib/honey_pot_engine/form_injector.rb', line 12

def form_for(record, options = {}, &block)
  super(record, options) do |form|
    concat hidden_honeypot_field
    block.call(form)
  end
end

#form_tag(url_for_options = {}, options = {}, &block) ⇒ Object

form_tag(非モデルベース)に対してもハニーポットを自動挿入



20
21
22
23
24
25
# File 'lib/honey_pot_engine/form_injector.rb', line 20

def form_tag(url_for_options = {}, options = {}, &block)
  super(url_for_options, options) do
    concat hidden_honeypot_field
    block.call
  end
end

#form_with(**options, &block) ⇒ Object

Railsのform_withをオーバーライドし、最初に隠しフィールドを挿入



4
5
6
7
8
9
# File 'lib/honey_pot_engine/form_injector.rb', line 4

def form_with(**options, &block)
  super(**options) do |form|
    concat hidden_honeypot_field
    block.call(form)
  end
end