Sha256: 1431ee037da7067a390d085d8e8c378bf99fbe4061c76725ca8ca8f964c4228d

Contents?: true

Size: 687 Bytes

Versions: 9

Compression:

Stored size: 687 Bytes

Contents

# frozen_string_literal: true

module MaintenanceStandards
  # Informs the user and redirects when needed
  #
  # @param result [Boolean] was update or create succesful
  # @param path [URL] where to redirect to
  # @param notice [String] What to show on success
  # @param error [String] What to show on error
  # @param render_action [Symbol] What to render
  #
  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
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
scribo-1.0.44 app/controllers/concerns/maintenance_standards.rb
scribo-1.0.43 app/controllers/concerns/maintenance_standards.rb
scribo-1.0.42 app/controllers/concerns/maintenance_standards.rb
scribo-1.0.41 app/controllers/concerns/maintenance_standards.rb
scribo-1.0.40 app/controllers/concerns/maintenance_standards.rb
scribo-1.0.39 app/controllers/concerns/maintenance_standards.rb
importo-2.0.5 app/controllers/concerns/maintenance_standards.rb
scribo-1.0.38 app/controllers/concerns/maintenance_standards.rb
importo-2.0.4 app/controllers/concerns/maintenance_standards.rb