Module: ViewsHelper

Defined in:
lib/colonel/server/helpers/views_helper.rb

Instance Method Summary collapse

Instance Method Details

#form_for(name, opts = {}, &block) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/colonel/server/helpers/views_helper.rb', line 2

def form_for(name, opts={}, &block)
  method = (opts[:method] == :get) ? 'GET' : 'POST'

  form_block = lambda {
    haml_concat(capture_haml {
      haml_tag :input, {type: 'hidden', name: '_method', value: opts[:method]}
    })
    haml_concat(capture_haml {
      block.call
    })
  }
  capture_haml do
    haml_tag :form, {action: opts[:url], method: method}.merge(opts[:html]), &form_block
  end
end


18
19
20
21
22
23
24
25
26
27
# File 'lib/colonel/server/helpers/views_helper.rb', line 18

def link_to(name, url, opts={})
  opts[:'data-method'] = opts.delete(:method) if opts[:method]
  opts[:'data-confirm'] = opts.delete(:confirm) if opts[:confirm]

  capture_haml do
    haml_tag :a, {href: url}.merge(opts) do
      haml_concat name
    end
  end
end

#selected?(period, i) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/colonel/server/helpers/views_helper.rb', line 29

def selected?(period, i)
  @job && @job.schedule.send(period).include?(i.to_s) && "selected"
end