Sha256: f532b2a6b120e5fbcdc97790a58ef2e88f2ca2456421714e8918b6a507161c9e

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

module Shoppe
  class TaxRatesController < Shoppe::ApplicationController
  
    before_filter { @active_nav = :tax_rates }
    before_filter { params[:id] && @tax_rate = Shoppe::TaxRate.find(params[:id]) }
  
    def index
      @tax_rates = Shoppe::TaxRate.ordered.all
    end
  
    def new
      @tax_rate = Shoppe::TaxRate.new
      render :action => "form"
    end
  
    def create
      @tax_rate = Shoppe::TaxRate.new(safe_params)
      if @tax_rate.save
        redirect_to :tax_rates, :flash => {:notice => "Tax rate has been created successfully"}
      else
        render :action => "form"
      end
    end
  
    def edit
      render :action => "form"
    end
  
    def update
      if @tax_rate.update(safe_params)
        redirect_to [:edit, @tax_rate], :flash => {:notice => "Tax rate has been updated successfully"}
      else
        render :action => "form"
      end
    end
  
    def destroy
      @tax_rate.destroy
      redirect_to :tax_rates, :flash => {:notice => "Tax rate has been removed successfully"}
    end
  
    private
  
    def safe_params
      params[:tax_rate].permit(:name, :rate, :country_ids => [])
    end
  
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shoppe-0.0.16 app/controllers/shoppe/tax_rates_controller.rb
shoppe-0.0.15 app/controllers/shoppe/tax_rates_controller.rb