sessions_controller.rb 551 Bytes
Newer Older
Zac Wood's avatar
Zac Wood committed
1
2
class SessionsController < ApplicationController
  def update
3
    update_cookie :crns
Zac Wood's avatar
Zac Wood committed
4
    update_cookie :section_ids
5
    update_cookie :semester_id
Zac Wood's avatar
Zac Wood committed
6
7
8
9

    head :ok
  end

10
  def cart
11
12
13
14
15
16
    section_id = params[:section_id]
    
    if @cart.include?(section_id)
      @cart.reject! { |id| section_id == id }
    else
      @cart << section_id
17
18
    end

19
20
21
    puts @cart.to_json
    cookies[:cart] = @cart.to_json
    render json: @cart.to_json
22
  end
23
24
    
  
25

Zac Wood's avatar
Zac Wood committed
26
27
28
29
30
31
  private

  def update_cookie(sym)
    cookies[sym] = params[sym] unless params[sym].nil?
  end
end