Skip to content

Commit

Permalink
Adapts redmine gemavatar to Redmine 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
fredsdc authored and alexbevi committed Jun 23, 2016
1 parent e6df7d2 commit 8aee249
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/acts_as_rated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def rated?
end

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

# Get the number of ratings for this object based on the special fields,
Expand Down Expand Up @@ -225,7 +225,7 @@ def rate value, rater = nil
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"
end
raise RateError, "rating with rater must receive a rater as parameter" if with_rater && (rater.nil? || rater.id.nil?)
r = with_rater ? ratings.find(:first, :conditions => ['rater_id = ?', rater.id]) : nil
r = with_rater ? ratings.where(:conditions => ['rater_id = ?', rater.id]).first : nil
raise RateError, "value is out of range!" unless acts_as_rated_options[:rating_range].nil? || acts_as_rated_options[:rating_range] === value

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


Expand Down
2 changes: 1 addition & 1 deletion lib/acts_as_viewed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def find_viewed_by viewer
raise ViewedError, 'Viewer must be a valid viewer' if !viewing_class.column_names.include? "viewer_id"
viewed_class = ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s
conds = [ 'viewed_type = ? AND viewer_id = ?', viewed_class, viewer.id ]
acts_as_viewed_options[:viewing_class].constantize.find(:all, :conditions => conds).collect {|r| r.viewed_type.constantize.find_by_id r.viewed.id }
acts_as_viewed_options[:viewing_class].constantize.where(:conditions => conds).collect {|r| r.viewed_type.constantize.find_by_id r.viewed.id }
end
end
end
Expand Down

0 comments on commit 8aee249

Please sign in to comment.