another big commit :D

This commit is contained in:
jomo
2013-10-07 04:59:21 +02:00
parent 2761387703
commit 5fac505a31
74 changed files with 1003 additions and 357 deletions
+8 -7
View File
@@ -1,15 +1,16 @@
class Blogpost < ActiveRecord::Base
attr_accessible :title, :text
validates_presence_of :title, :text, :user
belongs_to :user
has_many :comments
attr_accessible :title, :content, :author, :editor
validates_presence_of :title, :content, :author
belongs_to :user_author, class_name: "User", foreign_key: "user_author_id"
belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id"
has_many :comments, :dependent => :destroy
accepts_nested_attributes_for :comments
def author
@author ||= if user.present?
user
@author ||= if self.user_author.present?
user_author
else
User.find_by_name("Deleted user")
User.first
end
end
end