Archived
another big commit :D
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user