From 8c251da25d472e8cbdc7be23b80b91e6b223261a Mon Sep 17 00:00:00 2001 From: yanxd Date: Sat, 29 Mar 2014 10:47:37 +0800 Subject: [PATCH] =?UTF-8?q?Bug=EF=BC=9A=E6=96=B0=E5=BB=BA=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=97=B6=E8=8F=9C=E5=8D=95=E6=A0=8F=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=98=BE=E7=A4=BA=E8=93=9D=E8=89=B2=EF=BC=8C=E5=BA=94?= =?UTF-8?q?=E8=AF=A5=E6=98=AF=E7=AC=AC=E4=BA=8C=E4=B8=AA=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=93=9D=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 2 +- app/helpers/application_helper.rb | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 9076bb504..da5f44807 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -28,7 +28,7 @@ class ProjectsController < ApplicationController # menu_item l(:label_homework), :only => :homework # menu_item l(:label_course_feedback), :only => :feedback - menu_item :homework, :only => :homework + menu_item :homework, :only => [:homework, :new_homework] menu_item :feedback, :only => :feedback menu_item l(:label_course_file), :only => :index menu_item l(:label_course_news), :only => :index diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 815ac2236..1525105cc 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -36,13 +36,11 @@ module ApplicationHelper #Added by young #Define the course menu's link class + # 不是数组的转化成数组,然后判断当前menu_item是否在给定的列表 + # REVIEW: 目测menu的机制,貌似不是很需要转换,再说 def link_class(label) - if current_menu_item == label - @class = 'selected' - else - @class = '' - end - return @class + labels = label.is_a?(Array) ? label : ([] << label) + labels.include?(current_menu_item) ? 'selected' : '' end #Ended by young # Return true if user is authorized for controller/action, otherwise false