This repository has been archived on 2024-08-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
redstoner.com/app/models/comment.rb
2013-10-07 04:59:21 +02:00

17 lines
408 B
Ruby

class Comment < ActiveRecord::Base
attr_accessible :content, :author, :blogpost, :post
validates_presence_of :content, :author, :blogpost
validates_length_of :content, in: 4..1000
belongs_to :blogpost
belongs_to :user_author, class_name: "User", foreign_key: "user_author_id"
def author
@author ||= if self.user_author.present?
user_author
else
User.first
end
end
end