To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / plugins / redmine_bibliography / app / models / author.rb @ 1382:ac411172d897

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