app/models/commontator/comment.rb in commontator-4.10.0 vs app/models/commontator/comment.rb in commontator-4.10.1
- old
+ new
@@ -33,11 +33,11 @@
self.class.acts_as_votable
self.class.acts_as_votable_initialized = true
end
def get_vote_by(user)
- return nil unless is_votable? && user && user.is_commontator
+ return nil unless is_votable? && !user.nil? && user.is_commontator
votes_for.where(:voter_type => user.class.name, :voter_id => user.id).first
end
def update_cached_votes(vote_scope = nil)
self.update_column(:cached_votes_up, count_votes_up(true))
@@ -76,10 +76,10 @@
##################
# Access Control #
##################
def can_be_created_by?(user)
- user == creator && user.is_commontator &&\
+ user == creator && !user.nil? && user.is_commontator &&\
!thread.is_closed? && thread.can_be_read_by?(user)
end
def can_be_edited_by?(user)
return true if thread.can_be_edited_by?(user) &&\