Class WinkelController
In: app/controllers/winkel_controller.rb
Parent: ApplicationController

Deze controller bevat de belangrijkste methodes voor de werking van de winkel.

Methods

Public Instance methods

ingeven van klantgegevens:

[Source]

    # File app/controllers/winkel_controller.rb, line 36
36:     def aankoop_stap1
37:    if @kar.items.empty?
38:            redirect_to_index('Uw winkelkar is leeg')
39:       else
40:           @klant = Klant.new
41:       end
42:   end

ingeven van ordergegevens:

[Source]

    # File app/controllers/winkel_controller.rb, line 45
45:   def aankoop_stap2
46:    @order = Order.new
47:   end

[Source]

    # File app/controllers/winkel_controller.rb, line 49
49:    def bewaar_klant
50:       @klant= Klant.new(params[:klant])    
51:       if @klant.save      
52:          flash[:notice] = 'Uw gegevens zijn bewaard.'
53:          session[:klant] = @klant       # stockeer klant in session, id is nodig in order 
54:          redirect_to :action => :aankoop_stap2
55:       else
56:          render :action => :aankoop_stap1
57:       end
58:    end

[Source]

    # File app/controllers/winkel_controller.rb, line 60
60:    def bewaar_order
61:       @order = Order.new(params[:order])
62:       @order.klant = session[:klant]    # hier wordt klant_id door belongs_to ingevuld
63:       @order.toevoegen_orderlijnen_vanuit_kar(@kar)
64:        if @order.save
65:           session[:klant] = session[:kar] = nil     # opkuis session
66:           redirect_to_index("ITMedia dankt u voor uw bestelling!")
67:        else
68:           render :action => :aankoop_stap2
69:        end
70:    end

after_filter :copyright <— werkt wel, maar dan werkt AJAX niet meer!

[Source]

    # File app/controllers/winkel_controller.rb, line 9
 9:   def index
10:      @products = Product.find_producten_voor_verkoop
11:   end

[Source]

    # File app/controllers/winkel_controller.rb, line 30
30:   def leegmaken_kar
31:     session[:kar] = nil
32:     redirect_to_index('Uw winkelkar is leeg')
33:   end

[Source]

    # File app/controllers/winkel_controller.rb, line 13
13:   def toevoegen_aan_kar
14:       begin
15:         product = Product.find(params[:id])
16:       rescue ActiveRecord::RecordNotFound
17:         error = "U probeert een niet bestaand product #{params[:id]} op te halen"
18:         logger.error(error)
19:         redirect_to_index(error)
20:       else
21:          @kar.voeg_product_toe(product)
22:          if request.xhr?    # AJAX-request
23:              respond_to { |format| format.js }
24:          else
25:              redirect_to :action => :index
26:          end
27:       end
28:   end

Protected Instance methods

[Source]

    # File app/controllers/winkel_controller.rb, line 73
73:     def inlogcontrole
74:     end

[Validate]