Sha256: 3634154574d97792d87705104ac753ac5208c877bcdeab4d79b3ef3b0cda74e4

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module PoBox
  class InboxesController < ApplicationController
    before_action :set_inbox, only: %i[show edit update destroy]

    def index
      @inboxes = Inbox.all
    end

    def show
    end

    def new
      @inbox = Inbox.new
    end

    def edit
    end

    def create
      @inbox = Inbox.new(inbox_params)

      if @inbox.save
        redirect_to @inbox, notice: "Inbox was successfully created."
      else
        render :new, status: :unprocessable_entity
      end
    end

    def update
      if @inbox.update(inbox_params)
        redirect_to @inbox, notice: "Inbox was successfully updated."
      else
        render :edit, status: :unprocessable_entity
      end
    end

    def destroy
      @inbox.destroy
      redirect_to inboxes_url, notice: "Inbox was successfully destroyed."
    end

    private

    def inbox_params
      params.require(:inbox).permit(:emailable_type, :emailable_id, :address)
    end

    def set_inbox
      @inbox = Inbox.find(params[:id])
    rescue ActiveRecord::RecordNotFound
      redirect_to inboxes_path, notice: "Inbox not found"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
po_box-0.1.2 app/controllers/po_box/inboxes_controller.rb