class CreditCardBillsController < ApplicationController before_action :set_credit_card_bill, only: %i[ show edit update destroy ] # GET /credit_card_bills or /credit_card_bills.json def index @credit_card_bills = CreditCardBill.all end # GET /credit_card_bills/1 or /credit_card_bills/1.json def show end # GET /credit_card_bills/new def new @credit_card_bill = CreditCardBill.new end # GET /credit_card_bills/1/edit def edit end # POST /credit_card_bills or /credit_card_bills.json def create @credit_card_bill = CreditCardBill.new(credit_card_bill_params) respond_to do |format| if @credit_card_bill.save format.html { redirect_to credit_card_bill_url(@credit_card_bill), notice: "Credit card bill was successfully created." } format.json { render :show, status: :created, location: @credit_card_bill } else format.html { render :new, status: :unprocessable_entity } format.json { render json: @credit_card_bill.errors, status: :unprocessable_entity } end end end # PATCH/PUT /credit_card_bills/1 or /credit_card_bills/1.json def update respond_to do |format| if @credit_card_bill.update(credit_card_bill_params) format.html { redirect_to credit_card_bill_url(@credit_card_bill), notice: "Credit card bill was successfully updated." } format.json { render :show, status: :ok, location: @credit_card_bill } else format.html { render :edit, status: :unprocessable_entity } format.json { render json: @credit_card_bill.errors, status: :unprocessable_entity } end end end # DELETE /credit_card_bills/1 or /credit_card_bills/1.json def destroy @credit_card_bill.destroy respond_to do |format| format.html { redirect_to credit_card_bills_url, notice: "Credit card bill was successfully destroyed." } format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. def set_credit_card_bill @credit_card_bill = CreditCardBill.find(params[:id]) end # Only allow a list of trusted parameters through. def credit_card_bill_params params.require(:credit_card_bill).permit(:description, :amount) end end