Sha256: 681dcda5942ee8409b4527ce06cf55748d51b42971f104e546634c485b8c526e

Contents?: true

Size: 583 Bytes

Versions: 8

Compression:

Stored size: 583 Bytes

Contents

require_dependency "letter_opener_web/application_controller"

module LetterOpenerWeb
  class LettersController < ApplicationController
    def index
      @letters = Letter.search
    end

    def show
      letter = Letter.find(params[:id])
      text   = letter.send("#{params[:style]}_text").
        gsub(/"plain\.html"/, "\"#{letter_path(id: letter.id, style: 'plain')}\"").
        gsub(/"rich\.html"/, "\"#{letter_path(id: letter.id, style: 'rich')}\"")
      render text: text
    end

    def clear
      Letter.destroy_all
      redirect_to letters_path
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
letter_opener_web-1.0.0 app/controllers/letter_opener_web/letters_controller.rb
letter_opener_web-1.0.0.rc3 app/controllers/letter_opener_web/letters_controller.rb
letter_opener_web-1.0.0.rc2 app/controllers/letter_opener_web/letters_controller.rb
letter_opener_web-1.0.0.rc1 app/controllers/letter_opener_web/letters_controller.rb
letter_opener_web-0.0.4 app/controllers/letter_opener_web/letters_controller.rb
letter_opener_web-0.0.3 app/controllers/letter_opener_web/letters_controller.rb
letter_opener_web-0.0.2 app/controllers/letter_opener_web/letters_controller.rb
letter_opener_web-0.0.1 app/controllers/letter_opener_web/letters_controller.rb