Sha256: c84603601175670f45cecdecdb2838f6f0e667703c4c359dd5a93dc6d08de30f

Contents?: true

Size: 1.09 KB

Versions: 9

Compression:

Stored size: 1.09 KB

Contents

module KktShoppe
  class CountriesController < KktShoppe::ApplicationController

    before_filter { @active_nav = :countries }
    before_filter { params[:id] && @country = KktShoppe::Country.find(params[:id]) }

    def index
      @countries = KktShoppe::Country.ordered
    end

    def new
      @country = KktShoppe::Country.new
    end

    def create
      @country = KktShoppe::Country.new(safe_params)
      if @country.save
        redirect_to :countries, :flash => {:notice => t('kkt_shoppe.countries.create_notice')}
      else
        render :action => "new"
      end
    end

    def edit
    end

    def update
      if @country.update(safe_params)
        redirect_to [:edit, @country], :flash => {:notice => t('kkt_shoppe.countries.update_notice') }
      else
        render :action => "edit"
      end
    end

    def destroy
      @country.destroy
      redirect_to :countries, :flash => {:notice => t('kkt_shoppe.countries.destroy_notice')}
    end

    private

    def safe_params
      params[:country].permit(:name, :code2, :code3, :continent, :tld, :currency, :eu_member)
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
kkt_shoppe-2.0.2 app/controllers/kkt_shoppe/countries_controller.rb
kkt_shoppe-2.0.1 app/controllers/kkt_shoppe/countries_controller.rb
kkt_shoppe-2.0.0 app/controllers/kkt_shoppe/countries_controller.rb
kkt_shoppe-1.3.0 app/controllers/kkt_shoppe/countries_controller.rb
kkt_shoppe-1.2.1 app/controllers/kkt_shoppe/countries_controller.rb
kkt_shoppe-1.2.0 app/controllers/kkt_shoppe/countries_controller.rb
kkt_shoppe-1.1.2 app/controllers/kkt_shoppe/countries_controller.rb
kkt_shoppe-1.1.1 app/controllers/kkt_shoppe/countries_controller.rb
kkt_shoppe-1.1.0 app/controllers/kkt_shoppe/countries_controller.rb