Sha256: dca7354f78d691b9c5231d087c24ffce64300b80ceb410bdaedd533562da39d7

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

module Shoppe
  class CountriesController < Shoppe::ApplicationController
  
    before_filter { @active_nav = :countries }
    before_filter { params[:id] && @country = Shoppe::Country.find(params[:id]) }
  
    def index
      @countries = Shoppe::Country.ordered
    end
  
    def new
      @country = Shoppe::Country.new
    end
  
    def create
      @country = Shoppe::Country.new(safe_params)
      if @country.save
        redirect_to :countries, :flash => {:notice => "Country has been created successfully"}
      else
        render :action => "new"
      end
    end
  
    def edit
    end
  
    def update
      if @country.update(safe_params)
        redirect_to [:edit, @country], :flash => {:notice => "Country has been updated successfully"}
      else
        render :action => "edit"
      end
    end
  
    def destroy
      @country.destroy
      redirect_to :countries, :flash => {:notice => "Country has been removed successfully"}
    end
  
    private
  
    def safe_params
      params[:country].permit(:name, :code2, :code3, :continent, :tld, :currency, :eu_member)
    end
  
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
shoppe-1.0.2 app/controllers/shoppe/countries_controller.rb
shoppe-1.0.1 app/controllers/shoppe/countries_controller.rb
shoppe-1.0.0 app/controllers/shoppe/countries_controller.rb
shoppe-0.0.21 app/controllers/shoppe/countries_controller.rb
shoppe-0.0.20 app/controllers/shoppe/countries_controller.rb
shoppe-0.0.19 app/controllers/shoppe/countries_controller.rb