Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails (Rails+Redmine)根据用户角色在顶部菜单中显示选项卡_Ruby On Rails_Redmine_Redmine Api - Fatal编程技术网

Ruby on rails (Rails+Redmine)根据用户角色在顶部菜单中显示选项卡

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

我正在开发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 :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