Added validation for length of blogpost title and content.
This commit is contained in:
@@ -8,6 +8,8 @@ class Blogpost < ActiveRecord::Base
|
|||||||
belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id"
|
belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id"
|
||||||
has_many :comments, :dependent => :destroy
|
has_many :comments, :dependent => :destroy
|
||||||
accepts_nested_attributes_for :comments
|
accepts_nested_attributes_for :comments
|
||||||
|
validates_length_of :title, in: 5..255
|
||||||
|
validates_length_of :content, in: 5..20000
|
||||||
|
|
||||||
def author
|
def author
|
||||||
@author ||= if self.user_author.present?
|
@author ||= if self.user_author.present?
|
||||||
|
|||||||
Reference in New Issue
Block a user