<commit_before>class Admin::UsersController < Admin::AdminController
  before_filter :get_user,          :only => [:edit, :update, :destroy]
  before_filter :get_sites,         :only => [:new, :edit]

  def index
    params[:user]  = {'organization_id' => '-1'}.merge(params[:user] || {})

    @user          = User.new(params[:user])
    @users         = User.order('id asc')
    @users         = @users.filter_by_organization(params[:user])
    @users         = @users.paginate :per_page => 20, :order => 'name asc', :page => params[:page]
    @organizations = grouped_organizations
    render :partial => 'users' and return if request.xhr?

    respond_to do |format|
      format.html
      format.xls do
        send_data User.to_excel(params[:user]['organization_id']),
          :type        => 'application/vnd.ms-excel',
          :disposition => "attachment; filename=users.xls"
      end
    end
  end

  def new
    @user          = User.new
    @organizations = Organization.with_admin_user.all
  end

  def create
    @user = User.new(params[:user])
    if @user.save
      redirect_to :admin_users
    else
      @organizations = Organization.with_admin_user.all
      get_sites
      render :new
    end
  end

  def edit
    @organizations = Organization.with_admin_user.all
  end

  def update
    if @user.update_attributes(params[:user])
      redirect_to :admin_users
    else
      @organizations = Organization.with_admin_user.all
      get_sites
      render :edit
    end
  end
<commit_msg>Fixes a bug with user creation<commit_after>class Admin::UsersController < Admin::AdminController
  before_filter :get_user,          :only => [:edit, :update, :destroy]
  before_filter :get_sites,         :only => [:new, :edit]

  def index
    params[:user]  = {'organization_id' => '-1'}.merge(params[:user] || {})

    @user          = User.new(params[:user])
    @users         = User.order('id asc')
    @users         = @users.filter_by_organization(params[:user])
    @users         = @users.paginate :per_page => 20, :order => 'name asc', :page => params[:page]
    @organizations = grouped_organizations
    render :partial => 'users' and return if request.xhr?

    respond_to do |format|
      format.html
      format.xls do
        send_data User.to_excel(params[:user]['organization_id']),
          :type        => 'application/vnd.ms-excel',
          :disposition => "attachment; filename=users.xls"
      end
    end
  end

  def new
    @user          = User.new
    @organizations = Organization.all
  end

  def create
    @user = User.new(params[:user])
    if @user.save
      redirect_to :admin_users
    else
      @organizations = Organization.all
      get_sites
      render :new
    end
  end

  def edit
    @organizations = Organization.all
  end

  def update
    if @user.update_attributes(params[:user])
      redirect_to :admin_users
    else
      @organizations = Organization.all
      get_sites
      render :edit
    end
  end

{'fraction_non_alphanumeric': 0.11800201139792156, 'fraction_numerical': 0.002011397921555481, 'mean_word_length': 2.543942992874109, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '4727110', 'n_tokens_mistral': 943, 'n_tokens_neox': 910, 'n_words': 209}