Sha256: 5dad36065d0bf50e9b56b09d48ad4496eb883ff631f37404b2086e4e61ca1d41
Contents?: true
Size: 883 Bytes
Versions: 4
Compression:
Stored size: 883 Bytes
Contents
module IsActiveModelHelper def initialize(*args) super(*args) is_active = true if new_record? end def self.append_features(base) super base.class_eval do def self.find_active(*args) args[1] ||= {} conditions = args[1][:conditions] if conditions.class == String conditions = ['is_active = ? AND '+conditions,true] elsif ( conditions.respond_to?(:length) and conditions.length > 0 and conditions[0].class == String and conditions[0].length > 0 ) conditions = [ 'is_active = ? AND '+conditions[0], true ] + conditions[1..conditions.length] else conditions = [ 'is_active = ?', true ] end args[1][:conditions] = conditions self.find(*args) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems