README.md in ar-uuid-0.2.0 vs README.md in ar-uuid-0.2.1
- old
+ new
@@ -1,8 +1,8 @@
# ActiveRecord::UUID
-[![Travis-CI](https://travis-ci.org/fnando/ar-uuid.png)](https://travis-ci.org/fnando/ar-uuid)
+[![Travis-CI](https://travis-ci.org/fnando/ar-uuid.svg)](https://travis-ci.org/fnando/ar-uuid)
[![Code Climate](https://codeclimate.com/github/fnando/ar-uuid/badges/gpa.svg)](https://codeclimate.com/github/fnando/ar-uuid)
[![Test Coverage](https://codeclimate.com/github/fnando/ar-uuid/badges/coverage.svg)](https://codeclimate.com/github/fnando/ar-uuid/coverage)
[![Gem](https://img.shields.io/gem/v/ar-uuid.svg)](https://rubygems.org/gems/ar-uuid)
[![Gem](https://img.shields.io/gem/dt/ar-uuid.svg)](https://rubygems.org/gems/ar-uuid)
@@ -54,10 +54,29 @@
### Disadvantages
There is one big disadvantage on using uuid identifiers: you can't use methods like `ActiveRecord::FinderMethods::InstanceMethods#first` and `ActiveRecord::FinderMethods::InstanceMethods#last`, since they are scoped to the sequential id.
-Instead of `.first`, you can use [ActiveRecord::FinderMethods::InstanceMethods#take](https://github.com/rails/rails/blob/f52354ad1d15120dcc5284714bee7ee3f052986c/activerecord/lib/active_record/relation/finder_methods.rb#L104), which will use the order implemented by the database.
+The easiest alternative is ordering results and calling `first`/`last`. You can either create a sequence, or use the `created_at`/`updated_at` columns:
+
+```ruby
+# Get first record
+User.order(created_at: :asc).first
+
+# Get last record
+User.order(created_at: :desc).first
+
+# Use scopes
+class User < ApplicationRecord
+ scope :newer, -> { order(created_at: :desc) }
+ scope :older, -> { order(created_at: :asc) }
+end
+
+User.older.first
+User.newer.first
+```
+
+You can also replace `.first` with [ActiveRecord::FinderMethods::InstanceMethods#take](https://github.com/rails/rails/blob/f52354ad1d15120dcc5284714bee7ee3f052986c/activerecord/lib/active_record/relation/finder_methods.rb#L104), which will use the order implemented by the database.
There's no alternative to `.last`.
## Development