10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/helpers/is_active_model_helper.rb', line 10
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
|