Guest User

Untitled

a guest
Dec 11th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. def Address.has_access?(auth_account, site)
  2. account_id != auth_account.id && !auth_account.admin_at(site) && !auth_account.manager_at(site) && !auth_account.staff_at(site)
  3. end
  4.  
  5. class AddressesController < ApplicationController
  6. # other code was here
  7.  
  8. def delete
  9. @address=Address.find(params[:id])
  10.  
  11. if @address && @address.has_access?(@auth_account, @site)
  12. flash[:error]="You dont have permission to access this page"
  13. redirect_to root_url
  14. end
  15.  
  16. @address.destroy
  17. flash[:success]="Address deleted successfully"
  18.  
  19. redirect_to params[:landing] unless params[:landing].blank?
  20.  
  21. redirect_to index_checkout_url
  22. end
  23. end
Add Comment
Please, Sign In to add comment