touches comments and debates after changes
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
class Administrator < ActiveRecord::Base
|
class Administrator < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user, touch: true
|
||||||
delegate :name, :email, to: :user
|
delegate :name, :email, to: :user
|
||||||
|
|
||||||
validates :user_id, presence: true, uniqueness: true
|
validates :user_id, presence: true, uniqueness: true
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class Moderator < ActiveRecord::Base
|
class Moderator < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user, touch: true
|
||||||
delegate :name, :email, to: :user
|
delegate :name, :email, to: :user
|
||||||
|
|
||||||
validates :user_id, presence: true, uniqueness: true
|
validates :user_id, presence: true, uniqueness: true
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class Organization < ActiveRecord::Base
|
class Organization < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user, touch: true
|
||||||
|
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,17 @@ class User < ActiveRecord::Base
|
|||||||
scope :officials, -> { where("official_level > 0") }
|
scope :officials, -> { where("official_level > 0") }
|
||||||
scope :for_render, -> { includes(:organization) }
|
scope :for_render, -> { includes(:organization) }
|
||||||
|
|
||||||
|
after_update :touch_debates, :touch_comments
|
||||||
|
after_touch :touch_debates, :touch_comments
|
||||||
|
|
||||||
|
def touch_debates
|
||||||
|
debates.map(&:touch)
|
||||||
|
end
|
||||||
|
|
||||||
|
def touch_comments
|
||||||
|
comments.map(&:touch)
|
||||||
|
end
|
||||||
|
|
||||||
def self.find_for_oauth(auth, signed_in_resource = nil)
|
def self.find_for_oauth(auth, signed_in_resource = nil)
|
||||||
# Get the identity and user if they exist
|
# Get the identity and user if they exist
|
||||||
identity = Identity.find_for_oauth(auth)
|
identity = Identity.find_for_oauth(auth)
|
||||||
|
|||||||
Reference in New Issue
Block a user