Sha256: e1c6dbca45f8a2e9722f7c5651e7a8aa4ad69dae5843ff53f74677a3c990d903
Contents?: true
Size: 701 Bytes
Versions: 1
Compression:
Stored size: 701 Bytes
Contents
module RightnowOms module ControllerExtension extend ActiveSupport::Concern def has_cart? !@cart.nil? end 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 def load_cart(key = nil) key ||= :current_cart_id @cart = RightnowOms::Cart.find_by_id(session[key]) end def load_or_create_cart(name = nil) key = name ? "#{name}_cart_id".to_sym : :current_cart_id load_cart key unless has_cart? @cart = RightnowOms::Cart.create end session[:current_cart_id] = session[key] = @cart.id end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rightnow_oms-0.1.6 | lib/rightnow_oms/controller_extension.rb |