<commit_before>class User < ActiveRecord::Base
  
  has_and_belongs_to_many :roles
  
  # Include default devise modules. Others available are:
  # :token_authenticatable and :timeoutable
  devise :database_authenticatable, :registerable, :confirmable, :recoverable, 
         :rememberable, :trackable, :validatable, :lockable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me, :confirmed_at
    
  def role?(role)
    return !!Role.by_name(role)
  end
  
  # Make sure everyone always has at least the :user role.
  def role_ids=(val)
    logger.debug '================================'
    logger.debug val
    user_role = Role.by_name(:user)
    val << user_role.id unless val.include? user_role.id
    @role_ids = val
    logger.debug val
    logger.debug '================================'
    self.save
  end
  
end<commit_msg>Make sure all users have at least the :user role.<commit_after>class User < ActiveRecord::Base
  
  has_and_belongs_to_many :roles
  
  # Include default devise modules. Others available are:
  # :token_authenticatable and :timeoutable
  devise :database_authenticatable, :registerable, :confirmable, :recoverable, 
         :rememberable, :trackable, :validatable, :lockable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me, :confirmed_at
    
  def role?(role)
    return !!Role.by_name(role)
  end
  
  # Make sure all users have at least the :user role.
  def role_ids_with_add_user_role=(_role_ids) 
    user_role = Role.by_name(:user)
    _role_ids << user_role.id
    self[:role_ids] = _role_ids
    self.role_ids_without_add_user_role = _role_ids
   end 
   alias_method_chain :role_ids=, :add_user_role 
  
end
{'fraction_non_alphanumeric': 0.11706783369803063, 'fraction_numerical': 0.0, 'mean_word_length': 4.225714285714286, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2925335', 'n_tokens_mistral': 587, 'n_tokens_neox': 563, 'n_words': 149}