0
我正在構建一個模擬一些我最喜愛的應用程序的示例rails應用程序。我想實現照片回覆照片和照片的轉發 - 類似於您通過Twitter回覆和轉發的方式。我應該創建一個單獨的關係模型來捕獲照片回覆和轉貼,或者我應該處理照片模型中的所有內容。Twitter-Like「Reply and Retweet」Rails 3
class Photo < ActiveRecord::Base
attr_accessible :caption, :source, :source_remote_url, :source_file_name,
has_attached_file :source
validates_attachment_content_type :source
belongs_to :user
has_many :replies
has_many :reposts
def source_remote_url=(url_value)
self.source = URI.parse(url_value) unless url_value.blank?
super
end
def replies
join_table
end
def replies?(other_user)
join_table.find_by_replied_id(other_user.id)
end
def reply!(other_user)
join_table.create!(replied_id: other_user.id)
end