README.md in friendly_id-5.0.1 vs README.md in friendly_id-5.0.2

- old
+ new

@@ -14,17 +14,17 @@ **VERSION NOTE** **Rails 4**: -The master branch of this repository contains FriendlyId 5, which is compatible -with Rails 4. This version is in beta and will be released soon. +The master branch of this repository contains FriendlyId 5, the current stable version. +5.x is the only version that is compatible with Rails 4. **Rails 3**: If you wish to use this gem with Rails 3.1 or 3.2 you must use FriendlyId 4, -which is the current stable release. Please see the [4.0-stable +which is the previous stable release. Please see the [4.0-stable branch](https://github.com/norman/friendly_id/tree/4.0-stable). # FriendlyId <em>For the most complete, user-friendly documentation, see the [FriendlyId Guide](http://norman.github.io/friendly_id/file.Guide.html).</em> @@ -47,78 +47,73 @@ FriendlyId offers many advanced features, including: slug history and versioning, i18n, scoped slugs, reserved words, and custom slug generators. ### What Changed in Version 5.0 -As of version 5.0, FriendlyId uses semantic versioning. Therefore, as you might +As of version 5.0, FriendlyId uses [semantic versioning](http://semver.org/). Therefore, as you might infer from the version number, 5.0 introduces changes incompatible with 4.0. The most important changes are: * Finders are no longer overridden by default. If you want to do friendly finds, you must do `Model.friendly.find` rather than `Model.find`. You can however restore FriendlyId 4-style finders by using the `:finders` addon: - - friendly_id :foo, use: :slugged # you must do MyClass.friendly.find('bar') - # or... - friendly_id :foo, use: [:slugged, :finders] # you can now do MyClass.find('bar') - - + ```ruby + friendly_id :foo, use: :slugged # you must do MyClass.friendly.find('bar') + # or... + friendly_id :foo, use: [:slugged, :finders] # you can now do MyClass.find('bar') + ``` * A new "candidates" functionality which makes it easy to set up a list of alternate slugs that can be used to uniquely distinguish records, rather than appending a sequence. For example: - class Restaurant < ActiveRecord::Base - extend FriendlyId - friendly_id :slug_candidates, use: :slugged + ```ruby + class Restaurant < ActiveRecord::Base + extend FriendlyId + friendly_id :slug_candidates, use: :slugged - # Try building a slug based on the following fields in - # increasing order of specificity. - def slug_candidates - [ - :name, - [:name, :city], - [:name, :street, :city], - [:name, :street_number, :street, :city] - ] - end - end - + # Try building a slug based on the following fields in + # increasing order of specificity. + def slug_candidates + [ + :name, + [:name, :city], + [:name, :street, :city], + [:name, :street_number, :street, :city] + ] + end + end + ``` * Now that candidates have been added, FriendlyId no longer uses a numeric sequence to differentiate conflicting slug, but rather a UUID (e.g. something like `2bc08962-b3dd-4f29-b2e6-244710c86106`). This makes the codebase simpler and more reliable when running concurrently, at the expense of uglier ids being generated when there are conflicts. - * The default sequence separator has been changed from two dashes to one dash. - * Slugs are no longer regenerated when a record is saved. If you want to regenerate a slug, you must explicitly set the slug column to nil: - restaurant.friendly_id # joes-diner - restaurant.name = "The Plaza Diner" - restaurant.save! - restaurant.friendly_id # joes-diner - restaurant.slug = nil - restaurant.save! - restaurant.friendly_id # the-plaza-diner + ```ruby + restaurant.friendly_id # joes-diner + restaurant.name = "The Plaza Diner" + restaurant.save! + restaurant.friendly_id # joes-diner + restaurant.slug = nil + restaurant.save! + restaurant.friendly_id # the-plaza-diner + ``` You can restore some of the old behavior by overriding the `should_generate_new_friendly_id?` method. - * The `friendly_id` Rails generator now generates an initializer showing you - how to do some commmon global configuration. - + how to do some common global configuration. * The Globalize plugin has moved to a separate gem (currently in alpha). - * The `:reserved` module no longer includes any default reserved words. Previously it blocked "edit" and "new" everywhere. The default word list has been moved to `config/initializers/friendly_id.rb` and now includes many more words. - * The `:history` and `:scoped` addons can now be used together. - * Since it now requires Rails 4, FriendlyId also now requires Ruby 1.9.3 or higher. #### Upgrading from FriendlyId 4.0 @@ -131,13 +126,15 @@ `:slug` and `:sluggable_type` with a unique index on those two columns, plus the new `:scope` column. A migration like this should be sufficient: - add_column :friendly_id_slugs, :scope, :string - remove_index :friendly_id_slugs, [:slug, :sluggable_type] - add_index :friendly_id_slugs, [:slug, :sluggable_type] - add_index :friendly_id_slugs, [:slug, :sluggable_type, :scope], unique: true +```ruby +add_column :friendly_id_slugs, :scope, :string +remove_index :friendly_id_slugs, [:slug, :sluggable_type] +add_index :friendly_id_slugs, [:slug, :sluggable_type] +add_index :friendly_id_slugs, [:slug, :sluggable_type, :scope], unique: true +``` ## Docs The most current docs from the master branch can always be found [here](http://norman.github.io/friendly_id).