mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Word limit on user biography
This commit is contained in:
parent
5770920270
commit
5c044a801d
2 changed files with 36 additions and 8 deletions
|
|
@ -54,14 +54,8 @@ class User < ActiveRecord::Base
|
|||
},
|
||||
presence: true
|
||||
|
||||
##
|
||||
# Checkes if the user attended the event
|
||||
# This is used for events that require registration
|
||||
# The user must have registered to attend the event
|
||||
# Gets an event
|
||||
# === Returns
|
||||
# * +true+ if the user attended the event
|
||||
# * +false+ if the user did not attend the event
|
||||
validate :check_biography_length
|
||||
|
||||
def attended_event? event
|
||||
event_registration = event.events_registrations.find_by(registration: self.registrations)
|
||||
|
||||
|
|
@ -192,4 +186,13 @@ class User < ActiveRecord::Base
|
|||
self.is_admin = true
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
# Check if biography has an allowed number of words. Used as validation.
|
||||
#
|
||||
def check_biography_length
|
||||
if self.biography.present?
|
||||
errors.add(:biography, 'is limited to 150 words.') unless self.biography.split.length <= 150
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue