Module: RightnowOms::ControllerHelpers

Extended by:
ActiveSupport::Concern
Defined in:
lib/rightnow_oms/controller_helpers.rb

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) has_cart?

Returns:

  • (Boolean)


5
6
7
# File 'lib/rightnow_oms/controller_helpers.rb', line 5

def has_cart?
  !@cart.nil?
end

- (Object) load_cart



17
18
19
# File 'lib/rightnow_oms/controller_helpers.rb', line 17

def load_cart
  @cart = RightnowOms::Cart.find_by_id(session[:cart_id])
end

- (Object) load_or_create_cart



9
10
11
12
13
14
15
# File 'lib/rightnow_oms/controller_helpers.rb', line 9

def load_or_create_cart
  load_cart

  unless has_cart?
    @cart = RightnowOms::Cart.create! and session[:cart_id] = @cart.id
  end
end

- (Object) remove_null_params(data = params)



21
22
23
24
25
26
# File 'lib/rightnow_oms/controller_helpers.rb', line 21

def remove_null_params(data = params)
  data.each do |k, v|
    remove_null_params(v) if v.is_a? Hash
    data.delete(k) if v == 'null'
  end
end