Sha256: 4d84270458b0288d582d3914272184358b06d15c6a4076979fe17d4765950421

Contents?: true

Size: 936 Bytes

Versions: 2

Compression:

Stored size: 936 Bytes

Contents

class AlertsController < ApplicationController
  def direct
    swal {
      success 'direct', 'direct rendering'
      function 'function(){ alert("raw alert") }'
    }
    case params[:direct_type]
      when 'json'
        render json: {json: :json}
      when 'text'
        render plain: 'text'
      when 'xml'
        render xml: '<xml><body>html</body></xml>'
      else
        # do nothing
    end
  end


  def show
    case params[:swal_type]
      when 'success'
        swal { success 'Success', 'success text' }
      when 'info'
        swal { info 'Info', 'info text' }
      when 'warning'
        swal { warning 'Warning', 'warning text' }
      when 'error'
        swal { error 'Error', 'error text' }
      when 'preset'
        swal { preset 'Preset', 'preset text' }
      else
        # do nothing
    end

    render :index
  end


  def templater
    swal { success 'template test', 'templating' }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rough_swal-0.0.2 spec/dummy/app/controllers/alerts_controller.rb
rough_swal-0.0.1 spec/dummy/app/controllers/alerts_controller.rb