Sha256: 64accb3cb309fad87839c3b1a8d013ab9e26c627cde7cfc327d48280cf0ca506
Contents?: true
Size: 1.94 KB
Versions: 8
Compression:
Stored size: 1.94 KB
Contents
require_dependency "bookkeeper/application_controller" module Bookkeeper class PurchasesController < ApplicationController def index @purchases = Purchase.all respond_to do |format| format.html format.json { render json: @purchases } end end def show @purchase = Purchase.find(params[:id]) respond_to do |format| format.html format.json { render json: @purchase } end end def new @purchase = Purchase.new respond_to do |format| format.html format.json { render json: @purchase } end end def edit @purchase = Purchase.find(params[:id]) end def create @purchase = Purchase.new(params[:purchase]) respond_to do |format| if @purchase.save format.html { redirect_to purchases_path, notice: I18n.t('.bookkeeper.controllers.purchases.created') } format.json { render json: @purchase, status: :created, location: @purchase } else format.html { render action: "new" } format.json { render json: @purchase.errors, status: :unprocessable_entity } end end end def update @purchase = Purchase.find(params[:id]) respond_to do |format| if @purchase.update_attributes(params[:purchase]) format.html { redirect_to purchases_path, notice: I18n.t('.bookkeeper.controllers.purchases.updated') } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @purchase.errors, status: :unprocessable_entity } end end end def destroy @purchase = Purchase.find(params[:id]) @purchase.destroy flash[:notice] = I18n.t('.bookkeeper.controllers.purchases.destroyed') respond_to do |format| format.html { redirect_to purchases_url } format.json { head :no_content } end end end end
Version data entries
8 entries across 8 versions & 1 rubygems