annotate vendor/plugins/redmine_bibliography/app/models/author.rb @ 1169:492ff72268e3 bug_521

Close obsolete branch bug_521
author Chris Cannam
date Thu, 18 Oct 2012 10:42:48 +0100
parents 7097dc91e58e
children a0c9cc95bcf3
rev   line source
luis@328 1 class Author < ActiveRecord::Base
luis@468 2 has_many :authorships, :dependent => :destroy
luis@328 3 has_many :publications, :through => :authorships
luis@403 4
luis@466 5 belongs_to :user
luis@478 6
luis@478 7 def <=>(author)
luis@478 8 name.downcase <=> author.name.downcase
luis@478 9 end
luis@403 10
luis@477 11 named_scope :like, lambda {|q|
luis@477 12 s = "%#{q.to_s.strip.downcase}%"
luis@477 13 {:conditions => ["LOWER(name) LIKE :s", {:s => s}],
luis@477 14 :order => 'name'
luis@477 15 }
luis@478 16 }
luis@478 17
luis@328 18 end