view plugins/redmine_bibliography/app/models/author.rb @ 1126:e65c02706f1c redmine-2.2-integration

Changed file coding header from undefined to utf-8 (was raising an error).
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Tue, 08 Jan 2013 16:33:27 +0000
parents 807426fa6017
children 48d9b3ae9e1a
line wrap: on
line source
class Author < ActiveRecord::Base
  unloadable

  has_many :authorships, :dependent => :destroy
  has_many :publications, :through => :authorships

  belongs_to :user

  def <=>(author)
    name.downcase <=> author.name.downcase
  end

  # todo: review usage of scope --lf.20130108
  scope :like, lambda {|q|
    s = "%#{q.to_s.strip.downcase}%"
    {:conditions => ["LOWER(name) LIKE :s", {:s => s}],
     :order => 'name'
    }
  }

end