remove conditions on association deprecation warnings

This commit is contained in:
Jonne Haß 2013-08-31 14:11:08 +02:00
parent 89afb616cf
commit 2f54d4f17d
3 changed files with 9 additions and 9 deletions

View file

@ -10,7 +10,7 @@ class Conversation < ActiveRecord::Base
has_many :conversation_visibilities, :dependent => :destroy
has_many :participants, :class_name => 'Person', :through => :conversation_visibilities, :source => :person
has_many :messages, :order => 'created_at ASC'
has_many :messages, -> { order('created_at ASC') }
belongs_to :author, :class_name => 'Person'

View file

@ -44,7 +44,7 @@ class User < ActiveRecord::Base
has_many :invitations_from_me, :class_name => 'Invitation', :foreign_key => :sender_id
has_many :invitations_to_me, :class_name => 'Invitation', :foreign_key => :recipient_id
has_many :aspects, :order => 'order_id ASC'
has_many :aspects, -> { order('order_id ASC') }
belongs_to :auto_follow_back_aspect, :class_name => 'Aspect'
belongs_to :invited_by, :class_name => 'User'
@ -59,13 +59,13 @@ class User < ActiveRecord::Base
has_many :user_preferences
has_many :tag_followings
has_many :followed_tags, :through => :tag_followings, :source => :tag, :order => 'tags.name'
has_many :followed_tags, -> { order('tags.name') }, :through => :tag_followings, :source => :tag
has_many :blocks
has_many :ignored_people, :through => :blocks, :source => :person
has_many :conversation_visibilities, through: :person, order: 'updated_at DESC'
has_many :conversations, through: :conversation_visibilities, order: 'updated_at DESC'
has_many :conversation_visibilities, -> { order 'updated_at DESC' }, through: :person
has_many :conversations, -> { order 'updated_at DESC' }, through: :conversation_visibilities
has_many :notifications, :foreign_key => :recipient_id

View file

@ -6,15 +6,15 @@ module Diaspora
module Likeable
def self.included(model)
model.instance_eval do
has_many :likes, :conditions => {:positive => true}, :dependent => :delete_all, :as => :target
has_many :dislikes, :conditions => {:positive => false}, :class_name => 'Like', :dependent => :delete_all, :as => :target
has_many :likes, -> { where(positive: true) }, dependent: :delete_all, as: :target
has_many :dislikes, -> { where(positive: false) }, class_name: 'Like', dependent: :delete_all, as: :target
end
end
# @return [Integer]
def update_likes_counter
self.class.where(:id => self.id).
update_all(:likes_count => self.likes.count)
self.class.where(id: self.id).
update_all(likes_count: self.likes.count)
end
end
end