Module: RailsNavigationHelper

Defined in:
app/helpers/rails_navigation_helper.rb

Instance Method Summary collapse

Instance Method Details

#matches_page?(conditions) ⇒ Boolean

Returns:

  • (Boolean)


2
3
4
# File 'app/helpers/rails_navigation_helper.rb', line 2

def matches_page?(conditions)
  RailsNavigation::Matcher.match_multiple_with_or?(controller_name, action_name, params, conditions)
end


6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/helpers/rails_navigation_helper.rb', line 6

def nav_to(name, path, conditions = nil, html_options = {})
  active_class = []
  active_class = ['active'] if matches_page?(conditions)

  if html_options[:class]
    custom_classes = *html_options[:class]
    classes = active_class + custom_classes
  else
    classes = active_class
  end

  html_options[:class] = classes
  (:li, link_to(name, path), html_options)
end