Added validation for length of blogpost title and content.

This commit is contained in:
Logan Fick
2017-10-28 20:56:05 -04:00
parent 9aad746649
commit 82b4dd5280

View File

@@ -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?