Mercurial > hg > soundsoftware-site
view plugins/redmine_bibliography/app/models/author.rb @ 1419:fd6b09e93623 biblio_alt_search_auth
fixed name getter
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Tue, 01 Oct 2013 18:23:24 +0100 |
parents | 1df2db7f0e4d |
children | b688fe79f593 |
line wrap: on
line source
class Author < ActiveRecord::Base unloadable has_many :authorships, :dependent => :destroy has_many :publications, :through => :authorships belongs_to :user def <=>(author) name.downcase <=> author.name.downcase end # todo: review usage of scope --lf.20130108 scope :like, lambda {|q| s = "%#{q.to_s.strip.downcase}%" {:conditions => ["LOWER(name) LIKE :s", {:s => s}], :order => 'name' } } def institution if self.authorships.first.nil? "" else self.authorships.first.institution end end def mail if self.authorships.first.nil? "" else self.authorships.first.mail end end def name if self.name.nil? if self.authorships.first.nil? "" else self.authorships.first.name end end end end