Sha256: 0351601b2b8c5c632d95338ce0d62f9524968a615f7bff69151b52eaf3c7465c
Contents?: true
Size: 1.21 KB
Versions: 6
Compression:
Stored size: 1.21 KB
Contents
module Shoppe class AddressesController < Shoppe::ApplicationController before_filter { @active_nav = :customers } before_filter { params[:customer_id] && @customer = Shoppe::Customer.find(params[:customer_id])} before_filter { params[:id] && @address = @customer.addresses.find(params[:id])} def new @address = Shoppe::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
6 entries across 6 versions & 2 rubygems