Module: Admin::BaseHelper

Defined in:
app/helpers/admin/base_helper.rb

Instance Method Summary collapse

Instance Method Details

#clean(url) ⇒ Object



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

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

#current_url?(options) ⇒ Boolean

Returns:

  • (Boolean)


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

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


17
18
19
20
21
22
23
# File 'app/helpers/admin/base_helper.rb', line 17

def nav_link_to(name, options)
	if current_url?(options)
	  %{<strong>#{ link_to name, options }</strong>}
	else
 link_to name, options
	end
end