1

Please tell me, what's the purpose of the first argument in the simple_navigation configuration gem?

For example, look at this code:

SimpleNavigation::Configuration.run do |navigation|
  navigation.auto_highlight = false
  navigation.items do |primary|
    primary.item :report_errors, "Errors Log", report_errors_path
    primary.dom_class = 'nav pull-right'
  end
end

According to wiki:

a key (used for identifying the active navigation item in the controllers)

but as I noticed, :report_errors argument is only influences on the name of corresponding id attribute in HTML tag.

Thanks for reply.

4

1 回答 1

1

键是 Simple Navigation 将引用的 uniq 符号变量。您首先传递项目的键,然后传递将为此项目显示的字符串。

例子:

navigation.items do |primary|
  primary.item :my_books, 'My Books', books_path(user_id: current_user.id)
  primary.item :all_books, 'Show all books', books_path
  primary.item :his_books, 'Show his books', books_path(user_id: @other_user.id)
end

每个符号(键)必须是唯一的,以允许简单导航找到使用的项目。

于 2013-09-30T14:45:03.610 回答