Ruby on rails (Rails+Redmine)根据用户角色在顶部菜单中显示选项卡
我正在开发Redmine 1.4.x。我有两个角色:客户和员工。要分离我在数据库中添加的角色,请使用is_client boolean属性。以下是用例:Ruby on rails (Rails+Redmine)根据用户角色在顶部菜单中显示选项卡,ruby-on-rails,redmine,redmine-api,Ruby On Rails,Redmine,Redmine Api,我正在开发Redmine 1.4.x。我有两个角色:客户和员工。要分离我在数据库中添加的角色,请使用is_client boolean属性。以下是用例: if is_client? puts "it is client" else puts "it is employee" end 现在,根据这个角色,我必须在顶部菜单中显示门户选项卡。为此,我尝试了以下方法: Redmine::MenuManager.map :top_menu do |menu| menu.push :port
if is_client?
puts "it is client"
else
puts "it is employee"
end
现在,根据这个角色,我必须在顶部菜单中显示门户选项卡。为此,我尝试了以下方法:
Redmine::MenuManager.map :top_menu do |menu|
menu.push :portal, "#", :html => {:id => "emp_portal", :onclick => "OpenEmployeePortal()"} , :if => (Proc.new { User.current.is_client? } && Proc.new { User.current.logged? })
end
但我没能成功。它显示了两个角色的门户选项卡
那么我如何才能做到这一点呢?试试这个
Redmine::MenuManager.map :top_menu do |menu|
menu.push :portal, "#", :html => {:id => "emp_portal", :onclick => "OpenEmployeePortal()"} , :if => (Proc.new { User.current.is_client? && User.current.logged? })
end
试试这个
Redmine::MenuManager.map :top_menu do |menu|
menu.push :portal, "#", :html => {:id => "emp_portal", :onclick => "OpenEmployeePortal()"} , :if => (Proc.new { User.current.is_client? && User.current.logged? })
end