Archived
many tiny changes
This commit is contained in:
@@ -4,4 +4,12 @@ class Blogpost < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
has_many :comments
|
||||
accepts_nested_attributes_for :comments
|
||||
|
||||
def author
|
||||
@author ||= if user.present?
|
||||
user
|
||||
else
|
||||
User.find_by_name("Deleted user")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
class Comment < ActiveRecord::Base
|
||||
attr_accessible :text, :user, :blogpost, :post
|
||||
|
||||
validates_presence_of :text, :user, :blogpost
|
||||
validates_length_of :text, :in => 4..1000
|
||||
|
||||
|
||||
belongs_to :blogpost
|
||||
belongs_to :user
|
||||
end
|
||||
Reference in New Issue
Block a user