3989eecb0a59c9374f3c25a0821e0ea5

Is there easy and clever way to generate :conditions hash depending from user type?

def load_forums                         
    case current_user.type
      when "Admin"
        cond = {} 
      when "Owner"
        cond = {:forum_for => [1,3]}
      when "Provider"
        cond = {:forum_for => [2,3]}
      else 
        cond = {:forum_for => [3]}
    end
    Forum.all(:conditions => cond)
end

Refactorings

No refactoring yet !

Your refactoring





Format Copy from initial code

or Cancel