Module: MegaBar::ApplicationHelper

Defined in:
app/helpers/mega_bar/application_helper.rb

Instance Method Summary collapse

Instance Method Details



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/helpers/mega_bar/application_helper.rb', line 10

def link_path(action = nil, id = nil)
  # application helper
  action ||= params[:action]
  case action
  when 'index' #untested
    url_for(controller: params[:controller].to_s,
    action:  params[:action],
    only_path: true)
  when 'new' 
    url_for(controller: params[:controller].to_s,
    action:  'new',
    only_path: true)
  when 'edit'  #untested
    url_for(controller: params[:controller].to_s,
    action:  'edit',
    :id=>id,#catch errors
    only_path: true)
  when 'show'  #untested
    url_for(controller: params[:controller].to_s,
      :id => id,
      action:  'show',
      only_path: true
    )
  else
    form_path = 'tbd'
  end
end

#pre_renderObject



37
38
# File 'app/helpers/mega_bar/application_helper.rb', line 37

def pre_render
end

#sortable(column, title = nil) ⇒ Object



3
4
5
6
7
8
# File 'app/helpers/mega_bar/application_helper.rb', line 3

def sortable(column, title=nil)
  title ||= column.titleize
  css_class = column == sort_column ? "current #{sort_direction}" : nil
  direction = column == sort_column && sort_direction == 'asc' ? 'desc' : 'asc'
  link_to title, {:sort => column, :direction => direction}, class: css_class
end