To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / plugins / redmine_bibliography / app / models / author.rb @ 1412:48d9b3ae9e1a
History | View | Annotate | Download (501 Bytes)
| 1 | 328:aed18b463206 | luis | class Author < ActiveRecord::Base |
|---|---|---|---|
| 2 | 946:a0c9cc95bcf3 | luis | unloadable |
| 3 | 1123:48c5fdd6cf10 | luis | |
| 4 | 468:0bb9c7baed07 | luis | has_many :authorships, :dependent => :destroy |
| 5 | 328:aed18b463206 | luis | has_many :publications, :through => :authorships |
| 6 | 403:b15397a5341c | luis | |
| 7 | 466:a7dc708d48a1 | luis | belongs_to :user
|
| 8 | 478:7097dc91e58e | luis | |
| 9 | def <=>(author) |
||
| 10 | name.downcase <=> author.name.downcase |
||
| 11 | end
|
||
| 12 | 1123:48c5fdd6cf10 | luis | |
| 13 | 1124:807426fa6017 | luis | # todo: review usage of scope --lf.20130108
|
| 14 | 1123:48c5fdd6cf10 | luis | scope :like, lambda {|q|
|
| 15 | 477:aeedcec4df5f | luis | s = "%#{q.to_s.strip.downcase}%"
|
| 16 | {:conditions => ["LOWER(name) LIKE :s", {:s => s}],
|
||
| 17 | :order => 'name' |
||
| 18 | } |
||
| 19 | 478:7097dc91e58e | luis | } |
| 20 | |||
| 21 | 1412:48d9b3ae9e1a | luis | def institution |
| 22 | self.authorship.first.institution
|
||
| 23 | end
|
||
| 24 | 328:aed18b463206 | luis | end |