app/controllers/accounts_controller.rb
# toggle arrears status
# yes, I know I should be using ajax rather than re-rendering the entire page...
toggle arrears status
yes, I know I should be using ajax rather than re-rendering the entire page
toggle arrears status yes I know I should be using ajax rather than re - rendering the entire page
def toggle_arrears
    if !current_user.admin?
      redirect_to :jobs and return
    end
    account = Account.find(params[:id])
    type = params[:type]
    if account.arrears[type] == 'no'
      account.arrears[type] = 'yes'
    elsif account.arrears[type] == 'yes'
      account.arrears[type] = 'no'
    end
    if account.save
      Rails.logger.error("SAVE succeeded")
      flash[:notice] = "#{account.name} arrears policy changed"
      redirect_to :controller => '/accounts', :action => 'show', :id => account.id
    else
      Rails.logger.error("SAVE failed")
      flash[:alert] = "#{account.name} arrears policy not changed"
      redirect_to :controller => '/accounts', :action => 'show', :id => account.id
    end
  end
def toggle_arrears if ! current_user . admin? redirect_to :jobs and return end account = Account . find ( params [ :id ] ) type = params [ :type ] if account . arrears [ type ] == 'no' account . arrears [ type ] = 'yes' elsif account . arrears [ type ] == 'yes' account . arrears [ type ] = 'no' end if account . save Rails . logger . error ( "SAVE succeeded" ) flash [ :notice ] = "#{account.name} arrears policy changed" redirect_to :controller => '/accounts' , :action => 'show' , :id => account . id else Rails . logger . error ( "SAVE failed" ) flash [ :alert ] = "#{account.name} arrears policy not changed" redirect_to :controller => '/accounts' , :action => 'show' , :id => account . id end end
toggle arrears status
yes, I know I should be using ajax rather than re-rendering the entire page...
toggle arrears status yes I know I should be using ajax rather than re - rendering the entire page ...