mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Better form validation
This commit is contained in:
parent
fb24dfb129
commit
627e3b7b5f
3 changed files with 28 additions and 9 deletions
|
|
@ -14,11 +14,14 @@ class Event < ActiveRecord::Base
|
|||
belongs_to :room
|
||||
belongs_to :conference
|
||||
|
||||
accepts_nested_attributes_for :event_people
|
||||
accepts_nested_attributes_for :event_people, :allow_destroy => true
|
||||
accepts_nested_attributes_for :event_attachments, :allow_destroy => true, :reject_if => :all_blank
|
||||
accepts_nested_attributes_for :people
|
||||
before_create :generate_guid
|
||||
|
||||
validate :abstract_limit
|
||||
validates :title, :presence => true
|
||||
validates :abstract, :presence => true
|
||||
|
||||
state_machine :initial => :new do
|
||||
state :new
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ class Person < ActiveRecord::Base
|
|||
has_many :event_people, :dependent => :destroy
|
||||
has_many :events, :through => :event_people, :uniq => true
|
||||
has_many :registrations, :dependent => :destroy
|
||||
|
||||
validates :first_name, :presence => true
|
||||
validates :last_name, :presence => true
|
||||
validate :biography_limit
|
||||
|
|
@ -65,7 +66,7 @@ class Person < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def set_public_name
|
||||
if public_name.empty?
|
||||
if public_name.blank?
|
||||
self.public_name = "#{first_name} #{last_name}"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue