From 2c399fbe189b405096f5a486c4a78374bebf2f1a Mon Sep 17 00:00:00 2001 From: Torsten Date: Wed, 6 Sep 2023 12:51:16 +0300 Subject: [PATCH] add max length for profile and event --- app/models/event.rb | 4 ++-- app/models/profile.rb | 4 ++-- app/views/members/_profile_card.haml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index fbbfb24..4088ee5 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -1,8 +1,8 @@ class Event < ApplicationRecord belongs_to :profile - validates :name , presence: true - validates :text , presence: true + validates_length_of :name , minimum: 3 , maximum: 100 + validates_length_of :text, minimum: 30 , maximum: 1200 validates :start_date , presence: true validates :picture , presence: true diff --git a/app/models/profile.rb b/app/models/profile.rb index 82f8c53..64e44f3 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -2,9 +2,9 @@ class Profile < ApplicationRecord belongs_to :member has_many :events - validates :name , presence: true + validates_length_of :name , minimum: 3 , maximum: 100 + validates_length_of :bio , minimum: 30 , maximum: 600 validates :kind , presence: true - validates :bio , presence: true validates :picture , presence: true mount_uploader :picture, PictureUploader diff --git a/app/views/members/_profile_card.haml b/app/views/members/_profile_card.haml index 6b8fd99..3048586 100644 --- a/app/views/members/_profile_card.haml +++ b/app/views/members/_profile_card.haml @@ -12,4 +12,4 @@ %h5.m-4.text-3xl.font-bold.text-center = profile.name .mb-8.text-gray-800.text-center - .prose= markdown(profile.bio) + .prose= markdown(shorten(profile.bio))