Sha256: 681d10188944ec239cbef9bafc0e89eb3ee8bc0206f500f5975c92d38bb64d71

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

module LesliSecurity
  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

2 entries across 2 versions & 1 rubygems

Version Path
lesli_security-0.5.0 app/controllers/lesli_security/accounts_controller.rb
lesli_security-0.4.0 app/controllers/lesli_security/accounts_controller.rb