Merge branch 'emma'

* emma:
  Add Rails 3 / 2.3 instructions to README.
  Update Gemfile.lock with new PaperTrail version.
  Add note about symbolds in the meta hash.
  Promote patch version to 1.6.5.
  Add Emmanuel to list of contributors.
  Tie PaperTrail to Rails 2.3.
  Silence Rails 3 deprecation warnings.
This commit is contained in:
Andy Stewart 2011-02-08 13:26:11 +00:00
commit f56f619137
1 changed files with 12 additions and 15 deletions

View File

@ -2,25 +2,22 @@ class Version < ActiveRecord::Base
belongs_to :item, :polymorphic => true
validates_presence_of :event
named_scope :with_item_keys, lambda { |item_type, item_id| {
:conditions => { :item_type => item_type, :item_id => item_id }
} }
scope :with_item_keys, lambda { |item_type, item_id|
where(:item_type => item_type, :item_id => item_id)
}
named_scope :subsequent, lambda { |version| {
:conditions => ["id > ?", version.is_a?(ActiveRecord::Base) ? version.id : version],
:order => "id ASC",
} }
scope :subsequent, lambda { |version|
where(["id > ?", version.is_a?(Version) ? version.id : version]).order("id ASC")
}
named_scope :preceding, lambda { |version| {
:conditions => ["id < ?", version.is_a?(ActiveRecord::Base) ? version.id : version],
:order => "id DESC",
} }
scope :preceding, lambda { |version|
where(["id < ?", version.is_a?(Version) ? version.id : version]).order("id DESC")
}
named_scope :after, lambda { |timestamp| {
:conditions => ['created_at > ?', timestamp],
scope :after, lambda { |timestamp|
# TODO: is this :order necessary, considering its presence on the has_many :versions association?
:order => 'created_at ASC, id ASC'
} }
where(['created_at > ?', timestamp]).order('created_at ASC, id ASC')
}
# Restore the item from this version.
#