annotate plugins/redmine_bibliography/app/models/author.rb @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 807426fa6017
children 48d9b3ae9e1a
rev   line source
luis@328 1 class Author < ActiveRecord::Base
luis@946 2 unloadable
luis@1123 3
luis@468 4 has_many :authorships, :dependent => :destroy
luis@328 5 has_many :publications, :through => :authorships
luis@403 6
luis@466 7 belongs_to :user
luis@478 8
luis@478 9 def <=>(author)
luis@478 10 name.downcase <=> author.name.downcase
luis@478 11 end
luis@1123 12
luis@1124 13 # todo: review usage of scope --lf.20130108
luis@1123 14 scope :like, lambda {|q|
luis@477 15 s = "%#{q.to_s.strip.downcase}%"
luis@477 16 {:conditions => ["LOWER(name) LIKE :s", {:s => s}],
luis@477 17 :order => 'name'
luis@477 18 }
luis@478 19 }
luis@478 20
luis@328 21 end