README.md in permalink-1.2.2 vs README.md in permalink-1.3.0
- old
+ new
@@ -49,9 +49,27 @@
class Page < ActiveRecord::Base
permalink :title, :unique => true, :to_param => :permalink
end
```
+The permalink can be tied to a given scope. Let's say you want to have unique permalinks by user. Just set the `:scope` option.
+
+```ruby
+class Page < ActiveRecord::Base
+ belongs_to :user
+ permalink :title, :unique => true, :scope => :user_id
+end
+
+user = User.first
+another_user = User.last
+
+page = user.pages.create(title: 'Hello')
+page.permalink #=> hello
+
+another_page = another_user.pages.create(title: 'Hello')
+another_page.permalink #=> hello
+```
+
The permalink is generated using `ActiveSupport::Multibyte::Chars` class; this means that characters will properly replaced from `áéíó` to `aeio`, for instance.
The permalink is created when `before_validation` callback is evaluated. This plugin also tries
to generate a permalink when `before_save` callback is evaluated and the instance has no permalink set.