Module: DateCheckbox::FormHelper

Defined in:
lib/date_checkbox/form_helper.rb

Instance Method Summary collapse

Instance Method Details

#date_checkbox(attribute, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/date_checkbox/form_helper.rb', line 3

def date_checkbox(attribute, options = {})
  long, short = ( attribute.to_s =~ /_at$/ ) ?
    [ attribute, attribute.to_s.sub(/_at$/, '') ] :
    [ :"#{attribute}_at", attribute ]

  info = object.send(long).to_date if object.send(:"#{short}?")
  check_box(short) + info.to_s
end