diff --git a/config/initializers/url_helper.rb b/config/initializers/url_helper.rb new file mode 100644 index 000000000..7c4b68be9 --- /dev/null +++ b/config/initializers/url_helper.rb @@ -0,0 +1,22 @@ +# Time 2015-01-30 17:02:41 +# Author lizanle +# Description 打开redmine\ruby\lib\ruby\gems\1.9.1\gems\actionpack-3.2.13\lib\action_view\helpers\UrlHelper,重写link_to_unless方法 +# 如果是当前页,则给当前页添加样式:class=>'current-page' +module ActionView + # = Action View URL Helpers + module Helpers #:nodoc: + # Provides a set of methods for making links and getting URLs that + # depend on the routing subsystem (see ActionDispatch::Routing). + # This allows you to use the same format for links in views + # and controllers. + module UrlHelper + def link_to_unless(condition, name, options = {}, html_options = {}, &block) + if condition + link_to(name, options, html_options.merge(:class => 'current-page')) + else + link_to(name, options, html_options) + end + end + end + end +end \ No newline at end of file