Sha256: 6e48d74de568b29a7fcb88390d82b7929633d740aff98779456ffd5bba9d5757
Contents?: true
Size: 599 Bytes
Versions: 6
Compression:
Stored size: 599 Bytes
Contents
class Comment < ActiveRecord::Base belongs_to :post, inverse_of: :comments after_save :update_post_updated_at, source: :post before_create :set_post_title before_save :update_post_title, source: :post after_destroy source: :post do |comment, post| comment.update_attributes!(orphan_from_id: post.id) end private def set_post_title self.post_title = post.title end def update_post_title(post) update_attributes!(post_title: post.title) if post.title_changed? end def update_post_updated_at update_attributes!(post_updated_at: post.updated_at) end end
Version data entries
6 entries across 6 versions & 1 rubygems