Class: AddressesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- AddressesController
- Defined in:
- app/controllers/addresses_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/addresses_controller.rb', line 12 def create @address = current_user.addresses.new(params[:address]) if @address.save flash[:notice] = I18n.t('address_create_ok').capitalize return render :partial => 'list', :locals => { :addresses => current_user.addresses } else flash[:error] = @address.errors end end |
#destroy ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/addresses_controller.rb', line 41 def destroy @address = current_user.addresses.find_by_id(params[:id]) if @address.destroy flash[:notice] = I18n.t('address_update_ok').capitalize else flash[:error] = @address.errors end render :partial => 'list', :locals => { :addresses => current_user.addresses } end |
#edit ⇒ Object
26 27 28 |
# File 'app/controllers/addresses_controller.rb', line 26 def edit @address = current_user.addresses.find_by_id(params[:id]) end |
#index ⇒ Object
3 4 5 |
# File 'app/controllers/addresses_controller.rb', line 3 def index render :partial => 'list', :locals => { :addresses => current_user.addresses } end |
#new ⇒ Object
7 8 9 10 |
# File 'app/controllers/addresses_controller.rb', line 7 def new @address = current_user.addresses.new(params[:address]) render :action => 'create' end |
#show ⇒ Object
22 23 24 |
# File 'app/controllers/addresses_controller.rb', line 22 def show @address = current_user.addresses.find_by_id(params[:id]) end |
#update ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/addresses_controller.rb', line 30 def update @address = current_user.addresses.find_by_id(params[:id]) if @address.update_attributes(params[:address]) flash[:notice] = I18n.t('address_update_ok').capitalize return render :partial => 'list', :locals => { :addresses => current_user.addresses } else flash[:error] = @address.errors end render :action => 'edit' end |