Skip to content

Commit 8aee249

Browse files
fredsdcalexbevi
authored andcommitted
Adapts redmine gemavatar to Redmine 3.2
1 parent e6df7d2 commit 8aee249

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/acts_as_rated.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def rated?
192192
end
193193

194194
# last is the one where we don't keep the statistics - go direct to the db
195-
!ratings.find(:first).nil?
195+
!ratings.first.nil?
196196
end
197197

198198
# Get the number of ratings for this object based on the special fields,
@@ -225,7 +225,7 @@ def rate value, rater = nil
225225
raise RateError, "the rater object must be the one used when defining acts_as_rated (or a descendent of it). other objects are not acceptable"
226226
end
227227
raise RateError, "rating with rater must receive a rater as parameter" if with_rater && (rater.nil? || rater.id.nil?)
228-
r = with_rater ? ratings.find(:first, :conditions => ['rater_id = ?', rater.id]) : nil
228+
r = with_rater ? ratings.where(:conditions => ['rater_id = ?', rater.id]).first : nil
229229
raise RateError, "value is out of range!" unless acts_as_rated_options[:rating_range].nil? || acts_as_rated_options[:rating_range] === value
230230

231231
# Find the place to store the rating statistics if any...
@@ -273,7 +273,7 @@ def unrate rater
273273
end
274274
raise RateError, "Rater must be a valid and existing object" if rater.nil? || rater.id.nil?
275275
raise RateError, 'Cannot unrate if not using a rater' if !rating_class.column_names.include? "rater_id"
276-
r = ratings.find(:first, :conditions => ['rater_id = ?', rater.id])
276+
r = ratings.where(:conditions => ['rater_id = ?', rater.id]).first
277277
if !r.nil?
278278
target = self if attributes.has_key? 'rating_total'
279279
target ||= self.rating_statistic if acts_as_rated_options[:stats_class]
@@ -406,7 +406,7 @@ def find_rated_by rater
406406
raise RateError, "Rater must be an existing object with an id" if rater.id.nil?
407407
rated_class = ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s
408408
conds = [ 'rated_type = ? AND rater_id = ?', rated_class, rater.id ]
409-
acts_as_rated_options[:rating_class].constantize.find(:all, :conditions => conds).collect {|r| r.rated_type.constantize.find_by_id r.rated.id }
409+
acts_as_rated_options[:rating_class].constantize.where(:conditions => conds).collect {|r| r.rated_type.constantize.find_by_id r.rated.id }
410410
end
411411

412412

lib/acts_as_viewed.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def find_viewed_by viewer
258258
raise ViewedError, 'Viewer must be a valid viewer' if !viewing_class.column_names.include? "viewer_id"
259259
viewed_class = ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s
260260
conds = [ 'viewed_type = ? AND viewer_id = ?', viewed_class, viewer.id ]
261-
acts_as_viewed_options[:viewing_class].constantize.find(:all, :conditions => conds).collect {|r| r.viewed_type.constantize.find_by_id r.viewed.id }
261+
acts_as_viewed_options[:viewing_class].constantize.where(:conditions => conds).collect {|r| r.viewed_type.constantize.find_by_id r.viewed.id }
262262
end
263263
end
264264
end

0 commit comments

Comments
 (0)