Sha256: 8b1ea354ad84b5b3dc68504058c934495daadee0fe89326be6a6c01f2fdc2a7b

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

module LesliAudit
  class AccountsController < ApplicationController
    before_action :set_account, only: %i[ show edit update destroy ]

    # GET /accounts
    def index
      @accounts = Account.all
    end

    # GET /accounts/1
    def show
    end

    # GET /accounts/new
    def new
      @account = Account.new
    end

    # GET /accounts/1/edit
    def edit
    end

    # POST /accounts
    def create
      @account = Account.new(account_params)

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

    # PATCH/PUT /accounts/1
    def update
      if @account.update(account_params)
        redirect_to @account, notice: "Account was successfully updated.", status: :see_other
      else
        render :edit, status: :unprocessable_entity
      end
    end

    # DELETE /accounts/1
    def destroy
      @account.destroy
      redirect_to accounts_url, notice: "Account was successfully destroyed.", status: :see_other
    end

    private
      # Use callbacks to share common setup or constraints between actions.
      def set_account
        @account = Account.find(params[:id])
      end

      # Only allow a list of trusted parameters through.
      def account_params
        params.fetch(:account, {})
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lesli_audit-0.5.0 app/controllers/lesli_audit/accounts_controller.rb
lesli_audit-0.4.0 app/controllers/lesli_audit/accounts_controller.rb
lesli_audit-0.3.0 app/controllers/lesli_audit/accounts_controller.rb