Class: Spina::Admin::Conferences::Delegate
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Spina::Admin::Conferences::Delegate
- Defined in:
- app/models/spina/admin/conferences/delegate.rb
Overview
Delegate records.
Validators
- Presence
- Email address (using EmailAddressValidator)
- HTTP(S) URL (using HttpUrlValidator)
-
#url.
Instance Attribute Summary collapse
-
#conferences ⇒ ActiveRecord::Relation
Directly associated conferences.
-
#dietary_requirements ⇒ ActiveRecord::Relation
Directly associated dietary requirements.
-
#email_address ⇒ String?
The email address of the delegate.
-
#first_name ⇒ String?
The first name of the delegate.
-
#institution ⇒ Institution?
Directly associated institution.
-
#last_name ⇒ String?
The last name of the delegate.
-
#presentations ⇒ ActiveRecord::Relation
Directly associated presentations.
-
#url ⇒ String?
The website belonging to the delegate.
Class Method Summary collapse
-
.import(file) ⇒ void
Imports a conference from CSV.
Instance Method Summary collapse
-
#full_name ⇒ String
The first name and last name of the delegate.
-
#full_name_and_institution ⇒ String
The full name and institution of the delegate.
-
#reversed_name ⇒ String
The last name and first name of the delegate.
-
#reversed_name_and_institution ⇒ String
The reversed name and institution of the delegate.
-
#sorted ⇒ ActiveRecord::Relation
All delegates, ordered by last name and first name.
Instance Attribute Details
#conferences ⇒ ActiveRecord::Relation
Returns directly associated conferences.
34 35 |
# File 'app/models/spina/admin/conferences/delegate.rb', line 34 has_and_belongs_to_many :conferences, -> { includes(:translations) }, foreign_key: :spina_conferences_delegate_id, # rubocop:disable Rails/HasAndBelongsToMany association_foreign_key: :spina_conferences_conference_id |
#dietary_requirements ⇒ ActiveRecord::Relation
Returns directly associated dietary requirements.
44 45 |
# File 'app/models/spina/admin/conferences/delegate.rb', line 44 has_and_belongs_to_many :dietary_requirements, -> { includes(:translations) }, foreign_key: :spina_conferences_delegate_id, # rubocop:disable Rails/HasAndBelongsToMany association_foreign_key: :spina_conferences_dietary_requirement_id |
#email_address ⇒ String?
Returns the email address of the delegate.
|
|
# File 'app/models/spina/admin/conferences/delegate.rb', line 15
|
#first_name ⇒ String?
Returns the first name of the delegate.
|
|
# File 'app/models/spina/admin/conferences/delegate.rb', line 15
|
#institution ⇒ Institution?
Returns directly associated institution.
30 |
# File 'app/models/spina/admin/conferences/delegate.rb', line 30 belongs_to :institution, inverse_of: :delegates, touch: true |
#last_name ⇒ String?
Returns the last name of the delegate.
|
|
# File 'app/models/spina/admin/conferences/delegate.rb', line 15
|
#presentations ⇒ ActiveRecord::Relation
Returns directly associated presentations.
39 40 |
# File 'app/models/spina/admin/conferences/delegate.rb', line 39 has_and_belongs_to_many :presentations, -> { includes(:translations) }, foreign_key: :spina_conferences_delegate_id, # rubocop:disable Rails/HasAndBelongsToMany association_foreign_key: :spina_conferences_presentation_id |
#url ⇒ String?
Returns the website belonging to the delegate.
|
|
# File 'app/models/spina/admin/conferences/delegate.rb', line 15
|
Class Method Details
.import(file) ⇒ void
This method returns an undefined value.
Imports a conference from CSV.
55 56 57 |
# File 'app/models/spina/admin/conferences/delegate.rb', line 55 def self.import(file) DelegateImportJob.perform_later Pathname.new(file).read end |
Instance Method Details
#full_name ⇒ String
Returns the first name and last name of the delegate.
60 61 62 63 64 |
# File 'app/models/spina/admin/conferences/delegate.rb', line 60 def full_name return if first_name.blank? || last_name.blank? Delegate.human_attribute_name :full_name, first_name: first_name, last_name: last_name end |
#full_name_and_institution ⇒ String
Returns the full name and institution of the delegate.
67 68 69 70 71 |
# File 'app/models/spina/admin/conferences/delegate.rb', line 67 def full_name_and_institution return if full_name.blank? || institution.blank? Delegate.human_attribute_name :name_and_institution, name: full_name, institution: institution.name end |
#reversed_name ⇒ String
Returns the last name and first name of the delegate.
74 75 76 77 78 |
# File 'app/models/spina/admin/conferences/delegate.rb', line 74 def reversed_name return if first_name.blank? || last_name.blank? Delegate.human_attribute_name :reversed_name, first_name: first_name, last_name: last_name end |
#reversed_name_and_institution ⇒ String
Returns the reversed name and institution of the delegate.
81 82 83 84 85 |
# File 'app/models/spina/admin/conferences/delegate.rb', line 81 def reversed_name_and_institution return if reversed_name.blank? || institution.blank? Delegate.human_attribute_name :name_and_institution, name: reversed_name, institution: institution.name end |
#sorted ⇒ ActiveRecord::Relation
Returns all delegates, ordered by last name and first name.
25 |
# File 'app/models/spina/admin/conferences/delegate.rb', line 25 scope :sorted, -> { order :last_name, :first_name } |