Module: MaintenanceStandards

Included in:
Scribo::ApplicationAdminController
Defined in:
app/controllers/concerns/maintenance_standards.rb

Instance Method Summary collapse

Instance Method Details

#flash_and_redirect(result, path, notice, error, render_action = :edit) ⇒ Object

Informs the user and redirects when needed

Parameters:

  • result (Boolean)

    was update or create succesful

  • path (URL)

    where to redirect to

  • notice (String)

    What to show on success

  • error (String)

    What to show on error

  • render_action (Symbol) (defaults to: :edit)

    What to render



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/concerns/maintenance_standards.rb', line 12

def flash_and_redirect(result, path, notice, error, render_action = :edit)
  if result
    if params[:commit] == 'continue'
      flash.now[:notice] = notice
    else
      redirect_to(path, notice: notice) && return
    end
  else
    flash.now[:error] = error
  end
  render render_action
end