Class: Spina::Admin::Journal::Affiliation

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/spina/admin/journal/affiliation.rb

Overview

Rich join between an Institution and an Author. Associated with Articles via Authorships.

Since authors can in principle use different names in different articles, names are associated with affiilations, rather than with authors directly.

Validators

Presence

#first_name, #surname

Scopes

sorted

sorted by surname in alphabetical order

Instance Attribute Summary collapse

Instance Attribute Details

#articlesActiveRecord::Relation

Returns:



39
# File 'app/models/spina/admin/journal/affiliation.rb', line 39

has_many :articles, through: :authorships

#authorActiveRecord::Relation

Returns the Spina::Admin::Journal::Author whose affiliation this record holds.

Returns:



30
# File 'app/models/spina/admin/journal/affiliation.rb', line 30

belongs_to :author

#authorshipsActiveRecord::Relation

Returns directly associated Spina::Admin::Journal::Authorships.

Returns:



36
# File 'app/models/spina/admin/journal/affiliation.rb', line 36

has_many :authorships, dependent: :destroy

#first_nameString

Returns the first name(s) of the author.

Returns:

  • (String)

    the first name(s) of the author



30
# File 'app/models/spina/admin/journal/affiliation.rb', line 30

belongs_to :author

#institutionActiveRecord::Relation

Returns the Institution to which the author is affiliated.

Returns:

  • (ActiveRecord::Relation)

    the Institution to which the author is affiliated



33
# File 'app/models/spina/admin/journal/affiliation.rb', line 33

belongs_to :institution

#nameObject (readonly)



50
51
52
# File 'app/models/spina/admin/journal/affiliation.rb', line 50

def name
  "#{first_name} #{surname}"
end

#reversed_nameObject (readonly)



56
57
58
# File 'app/models/spina/admin/journal/affiliation.rb', line 56

def reversed_name
  "#{surname}, #{first_name}"
end

#statusInteger

Returns the status of the author, which can be either primary (1) or other (0).

Returns:

  • (Integer)

    the status of the author, which can be either primary (1) or other (0)



30
# File 'app/models/spina/admin/journal/affiliation.rb', line 30

belongs_to :author

#surnameString

Returns the last name(s) of the author.

Returns:

  • (String)

    the last name(s) of the author



30
# File 'app/models/spina/admin/journal/affiliation.rb', line 30

belongs_to :author