Guest User

Untitled

a guest
Jun 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. class StoresController < Spree::BaseController
  2. # Filters
  3. #
  4. before_filter :find_order
  5. before_filter :do_security, :only => [:index, :show]
  6.  
  7. def index
  8. @stores = DeliveryArea.active.find(current_user.delivery_area).stores.active
  9. respond_to do |format|
  10. format.html # index.html.erb
  11. format.xml { render :xml => @stores }
  12. end
  13. end
  14.  
  15. # GET /stores/1
  16. # GET /stores/1.xml
  17. def show
  18. @store = Store.find(params[:id])
  19. @specials = @store.products.active.special
  20. @favourites = @store.products.active.favourite
  21. respond_to do |format|
  22. format.html # show.html.erb
  23. format.xml { render :xml => @store }
  24. end
  25. end
  26.  
  27. private
  28. # If the user is anonymous, they'll need to sign up.
  29. # If the user is already logged in, they shouldn't be able to access 'new' or 'create'.
  30. #
  31. def do_security
  32. if current_user.is_anonymous?
  33. redirect_to :controller => "home", :action => "index"
  34. end
  35. end
  36.  
  37. end
Add Comment
Please, Sign In to add comment