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 @ 1403:35732ac4324a
History | View | Annotate | Download (439 Bytes)
| 1 |
class Author < ActiveRecord::Base |
|---|---|
| 2 |
unloadable |
| 3 |
|
| 4 |
has_many :authorships, :dependent => :destroy |
| 5 |
has_many :publications, :through => :authorships |
| 6 |
|
| 7 |
belongs_to :user
|
| 8 |
|
| 9 |
def <=>(author) |
| 10 |
name.downcase <=> author.name.downcase |
| 11 |
end
|
| 12 |
|
| 13 |
# todo: review usage of scope --lf.20130108
|
| 14 |
scope :like, lambda {|q|
|
| 15 |
s = "%#{q.to_s.strip.downcase}%"
|
| 16 |
{:conditions => ["LOWER(name) LIKE :s", {:s => s}],
|
| 17 |
:order => 'name' |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
end
|