<commit_before>module AccessHelper
  def authorize
    unless action_allowed?
      flash_msg
      redirect_back
    end
  end

  def flash_msg
    flash[:error] = 'Permission Denied'
  end

  def action_allowed?
    false #default action allowed is false. So to allow any action, we need to override this in the controller.
  end
end<commit_msg>Show a descriptive permission denied error with controller#action and Role<commit_after>module AccessHelper
  def authorize
    unless action_allowed?
      flash_msg
      redirect_back
    end
  end

  def flash_msg
    flash[:error] = "Permission Denied to #{params[:controller]}##{params[:action]} to role #{current_role_name}"
  end

  def action_allowed?
    false #default action allowed is false. So to allow any action, we need to override this in the controller.
  end
end
{'fraction_non_alphanumeric': 0.05669481302774427, 'fraction_numerical': 0.0, 'mean_word_length': 3.585635359116022, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6483662', 'n_tokens_mistral': 232, 'n_tokens_neox': 223, 'n_words': 91}