Sha256: b7dba273ca6c86b022e71e48ee49fdc71ad51d36b664d769d2a5f509c8d29b06
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
module KktShoppe class AddressesController < KktShoppe::ApplicationController before_filter { @active_nav = :customers } before_filter { params[:customer_id] && @customer = KktShoppe::Customer.find(params[:customer_id])} before_filter { params[:id] && @address = @customer.addresses.find(params[:id])} def new @address = KktShoppe::Address.new end def edit end def create @address = @customer.addresses.build(safe_params) if @customer.addresses.count == 0 @address.default = true end if @customer.save redirect_to @customer, :flash => {:notice => "Address has been created successfully"} else render action: "new" end end def update if @address.update(safe_params) redirect_to @customer, :flash => {:notice => "Address has been updated successfully"} else render action: "edit" end end def destroy @address.destroy redirect_to @customer, :flash => {:notice => "Address has been deleted successfully"} end private def safe_params params[:address].permit(:address_type, :address1, :address2, :address3, :address4, :postcode, :country_id) end end end
Version data entries
3 entries across 3 versions & 1 rubygems