From c543a28cc82b0dbcb712ecbedb6d8a089b3ea9f3 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 30 Jan 2015 17:24:26 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=86=99url=5Fhelper=20link=5Fto=5Fun?= =?UTF-8?q?less=E6=96=B9=E6=B3=95=EF=BC=8C=E7=BB=99Kaminari=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E9=A1=B5=E6=B7=BB=E5=8A=A0=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/initializers/url_helper.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 config/initializers/url_helper.rb 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