app/controllers/user_controller.rb
# edit a single user in order to add them to a group,
# and so on...
edit a single user in order to add them to a group,
and so on
edit a single user in order to add them to a group and so on
def show_user
    if !current_user.admin?
      redirect_to :jobs and return
    end
    @user = User.find(params[:id])
    if request.post?
      begin
      @account = Account.find(params[:account][:id])
      old_account = Account.first(:users => @user.id)
      old_account.users.delete(@user.id)
      old_account.save!
      @account.users << @user.id
      @account.users.uniq!
      @user.account = @account.id
      rescue
        Rails.logger.error("Failed to change account for user: #{@user.id}")
        redirect_to :controller => '/user', :action => 'show_user', :id => @user.id
        return
      end
      if @account.save! and @user.save!
        flash[:notice] = "Account updated successfully!"
      else
        flash[:alert] = "Error updating account!"
      end
      redirect_to :controller => '/user', :action => 'show_user', :id => @user.id
    else
      @account = Account.first(:users => @user.id)
    end
  end
def show_user if ! current_user . admin? redirect_to :jobs and return end @user = User . find ( params [ :id ] ) if request . post? begin @account = Account . find ( params [ :account ] [ :id ] ) old_account = Account . first ( :users => @user . id ) old_account . users . delete ( @user . id ) old_account . save! @account . users << @user . id @account . users . uniq! @user . account = @account . id rescue Rails . logger . error ( "Failed to change account for user: #{@user.id}" ) redirect_to :controller => '/user' , :action => 'show_user' , :id => @user . id return end if @account . save! and @user . save! flash [ :notice ] = "Account updated successfully!" else flash [ :alert ] = "Error updating account!" end redirect_to :controller => '/user' , :action => 'show_user' , :id => @user . id else @account = Account . first ( :users => @user . id ) end end
edit a single user in order to add them to a group,
and so on...
edit a single user in order to add them to a group and so on ...
# process the form and save the user # This should be a unique key if I understand the mongo_mapper documentation # correctly, but it seems happy to have the same value inserted multiple times. # I'm damned if I know why...