Search code examples
ruby-on-railsredmineredmine-api

(Rails + Redmine) Display tab in the top menu depending upon user role


I am working on Redmine 1.4.x. I have two roles: client and employee. To separate the roles I have added is_client boolean attribute to the database. Here is the use case:

if is_client?
  puts "it is client"
else
  puts "it is employee"
end

Now depending upon this role I have to display Portal tab in the top menu. To achieve this I tried the following:

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

But I couldn't succeed. It is showing the portal tab for both roles.

So how can I achieve this?


Solution

  • Try this

    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