Module: RadminHelper

Defined in:
app/helpers/radmin_helper.rb

Instance Method Summary collapse

Instance Method Details

#adminObject



17
18
19
# File 'app/helpers/radmin_helper.rb', line 17

def admin
  Radmin::AdminUI.instance
end

#clean(url) ⇒ Object



12
13
14
15
# File 'app/helpers/radmin_helper.rb', line 12

def clean(url)
  uri = URI.parse(url)
  uri.path.gsub(%r{/+}, '/').gsub(%r{/$}, '')
end

#current_tab?(tab) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
# File 'app/helpers/radmin_helper.rb', line 25

def current_tab?(tab)
  @current_tab ||= tab if tab.any? {|item| current_url?(item.relative_url) }
  @current_tab == tab
end

#current_url?(options) ⇒ Boolean

Returns:

  • (Boolean)


2
3
4
5
6
7
8
9
10
# File 'app/helpers/radmin_helper.rb', line 2

def current_url?(options)
  url = case options
  when Hash
    url_for options
  else
    options.to_s
  end
  request.fullpath =~ Regexp.new('^' + Regexp.quote(clean(url)))
end

#has_role?(role) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'app/helpers/radmin_helper.rb', line 46

def has_role?(role)
  current_admin.role_symbols.include?(role.to_sym)
end


30
31
32
33
34
35
# File 'app/helpers/radmin_helper.rb', line 30

def nav_link_to(name, options)
  klass = current_url?(options) ? "current" : ""
   :li, :class => "#{klass}" do
    link_to name, options
  end
end


21
22
23
# File 'app/helpers/radmin_helper.rb', line 21

def nav_tabs
  admin.nav
end

#show_title?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/helpers/radmin_helper.rb', line 42

def show_title?
  @show_title
end

#title(page_title, show_title = true) ⇒ Object



37
38
39
40
# File 'app/helpers/radmin_helper.rb', line 37

def title(page_title, show_title = true)    
  content_for(:title) { page_title.to_s }
  @show_title = show_title
end