ruby on rails - How to check if the user should be assigned the role admin -
the goal of method check when user signs up, if on list of users should admins.
i new ruby , think syntax error:
  def set_role     if self[:email] == ("email@gmail.com" || "sample@gmail.com" || "test@gmail.com")         self[:role] = "admin"      else       self[:role] = "customer"     end   end      
this time use case statement:
def set_role   self[:role] = case self[:email]                 when "email@gmail.com", "sample@gmail.com", "test@gmail.com"                   'admin'                 else                   'customer'                 end end   it's easy add new values when test.
Comments
Post a Comment