diff --git a/app/models/conversation.rb b/app/models/conversation.rb index ae776cd54..c620efe53 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -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' diff --git a/app/models/user.rb b/app/models/user.rb index 61d61b299..a37149603 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/lib/diaspora/likeable.rb b/lib/diaspora/likeable.rb index 9e05c79b3..bbb84d2ce 100644 --- a/lib/diaspora/likeable.rb +++ b/lib/diaspora/likeable.rb @@ -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