Sha256: 3282f52a4836cef5f525383683b3c71aa5ec4270fe8c4b20da8c9931f09ec37d

Contents?: true

Size: 1.05 KB

Versions: 10

Compression:

Stored size: 1.05 KB

Contents

module Tienda
  class CountriesController < Tienda::ApplicationController

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

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

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

    def create
      @country = Tienda::Country.new(safe_params)
      if @country.save
        redirect_to :countries, flash: { notice: t('tienda.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('tienda.countries.update_notice') }
      else
        render action: "edit"
      end
    end

    def destroy
      @country.destroy
      redirect_to :countries, flash: { notice: t('tienda.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

10 entries across 10 versions & 1 rubygems

Version Path
tienda-2.1.3 app/controllers/tienda/countries_controller.rb
tienda-2.1.2 app/controllers/tienda/countries_controller.rb
tienda-2.1.1 app/controllers/tienda/countries_controller.rb
tienda-2.1.0 app/controllers/tienda/countries_controller.rb
tienda-2.0.2 app/controllers/tienda/countries_controller.rb
tienda-2.0.1 app/controllers/tienda/countries_controller.rb
tienda-1.1.2 app/controllers/tienda/countries_controller.rb
tienda-1.1.1 app/controllers/tienda/countries_controller.rb
tienda-1.1.0 app/controllers/tienda/countries_controller.rb
tienda-1.0.0 app/controllers/tienda/countries_controller.rb