|
|
| 15 |
16 |
|
| 41 | 41 | end |
| 42 | 42 | |
| 43 | 43 | # options are :culprit, :referenced, :activity_loggable, :limit |
| 44 | | def self.find_for(options={}) |
| 44 | def self.find_with(options={}) |
| 45 | 45 | limit = (options.delete(:limit) || 10) |
| 46 | 46 | conditions = [] |
| 47 | 47 | conditions << self.send(:sanitize_sql, ["culprit_id = ?", options[:culprit]]) if options.keys.include? :culprit |
| 48 | 48 | conditions << self.send(:sanitize_sql, ["referenced_id = ?", options[:referenced]]) if options.keys.include? :referenced |
| 49 | 49 | conditions << self.send(:sanitize_sql, ["activity_loggable_id = ?", options[:activity_loggable]]) if options.keys.include? :activity_loggable |
| 50 | | self.find(:all, :conditions => conditions, :limit => limit) |
| 51 | | # rescue |
| 52 | | # raise "I couldn't run the find with the options you gave me" |
| 50 | self.find(:all, :conditions => conditions.join(" AND "), :limit => limit) |
| 51 | rescue |
| 52 | raise "I couldn't run the find with the options you gave me, sorry" |
| 53 | 53 | end |
| 54 | 54 | |
| 55 | 55 | private |