We would like to think our many {file:Contributors contributors} for suggestions, ideas and improvements to FriendlyId.
- Table of Contents {:toc}
This is a complete rewrite of FriendlyId, and introduces a smaller, faster and less ambitious codebase. The primary change is the relegation of external slugs to an optional addon, and the adoption of what were formerly "cached slugs" as the primary way of handling slugging.
This is a compatiblity branch and will be maintained for apps that can't upgrade to 4.0. No new features are planned, only bugfixes. If you're creating a new app, please use 4.x.
- Support for Active Record 2.3 dropped
- Convert blank slugs to nil automatically (Gabe da Silveira )
- Compatibility with Active Record 3.1 (Andrew White)
- Gemspec compatibility with RubyGems 1.7 (Philip Arndt)
- Fixed generators for Rails 3.1 (Matt Burke)
- Rake task fix for models with primary keys not named "id" (Danny Hawkins)
- Fixed minor issue with ActiveRecord 3.0.4.rc1 (Bruno Michel)
- Added support for Rubygems-test
- Fixed deprecation on Rails edge. Thanks slbug
- Removes
:scope
as a find parameter, allowing more flexible finds with scoped records. - Improve logic of
friendly_id:redo_slugs
to support models with non-numeric ids. (thanks Oleksandr Petrov)
- Fix compatibility with Active Record 3.0.3.
- Reserved words can now be regular expressions.
- Fix broken SQL when finding with a nil scope on AR3 (Tony Primerano)
- Slug#sluggable now works around default scopes (Cyrille Stepanyk)
- Explicitly make slug attributes accessible (William Melody)
- Improve abstraction support for DataMapper and Sequel (Alex Coles).
- Fix missing sluggable type in AR3 slug query. This was a fairly major oversight, and if you are using 3.1.4 or 3.1.5, you should update right away.
- Fix scoped queries when the model has a cached slug column. Bascially, the cached slug is now completely ignored when a scope is configured.
- Fix invalid empty symbol with 1.8.x.
- Significantly improve performance of queries using slugs with no cache on AR3.
- Fix callbacks being invoked after setting cached slugs.
- Add validations to some configuration params.
- Reverted approach to read-only fix from previous release. See this commit for details.
- Fixed records being returned read-only. (Thanks Luis Lavena)
- Don't assume relations are subclasses of ActiveRecord::Base. This fixes using FriendlyId with Static Model. (Thanks Luis Lavena)
- Avoid checking for dependent scopes when no models are using the scopes feature.
- Fixed call to method on nil value for failing unfriendly finds (thanks jlippiner)
- Refactored/simplified Active Record 2 and 3 query code.
- Better support for Active Record 3 finds and scopes.
- Extract slug handling code into separate gem, Babosa.
:max-length
option now uses bytes rather than characters.- Fix quoting issue that prevented using a domain- or database-qualified column. (thanks James Cropcho)
- Support for Active Record 2.2.x dropped; 2.3 or above is now required.
- Fixed a few small errors on Postgres.
- Improved porability for Sequel and in-progress DataMapper adapter.
- Fix bad call to apply_mapping on 2.3.
- Fixed support for Rails 3.0 beta4 (Bruno Michel)
- Made rake tasks skip validations (Emilio Tagua).
- Fixed incorrect status of records found with a numeric friendly_id.
- Made slug an explicit has_one relation to enable eager-loading via :include => :slug
- Fixed backwards-compatiblity with ActiveSupport 2.3.4 (Thanks Juergen Fesslmeier).
- Fixed scope update when models use polymorphic relations.
- Fixed finding non-slugged models by an array of ids.
- Added backported
tidy_bytes
implementation from utf8_utils - Removed dependency on Rubygems 1.3.6; this blocked deploy on Heroku (thanks Steven Noble)
- Replaced File.dirname calls with File.expand_path, which should allow compatibility with Ruby 1.9.2
- Cleanups and some improvements to tests.
- Fixed bad path in Rails 2.x generator.
- Rails 3 support.
- Removed features deprecated in FriendlyId 2.3.
- Fixed searching by numeric friendly_id in non-slugged models.
- Added
:allow_nil
config option (Andre Duffeck and Norman Clarke)
- Made slugged status use the slug sequence. This fixes problems with #best? returning false when finding with a sequenced slug.
- Doc fixes. (Juan Schiwndt)
- Misc cleanups.
- Fixed sequence regexp to grab all trailing digits. (Nash Kabbara)
- Block param now warns, not raises. (Kamal Fariz Mahyuddin)
- Misc doc fixes. (Kamal Fariz Mahyuddin)
- Fixed finding by old slug when using cached slugs.
- Sequence separator parsing now correctly handles occurrences of the sequence separator string inside the friendly_id text (Johan Kok).
- Fixed missing quotes on table names in a few places (Brian Collins).
- Fixed stack level too deep error on #strip_diacritics.
This is a major update à la "Snow Leopard" that adds no new major features, but significantly improves the underlying code. Most users should be able to upgrade with no issues other than new deprecation messages appearing in the logs.
If, however, you have monkey-patched FriendlyId, or are maintaining your own fork, then this upgrade may causes issues.
Changes:
- Sequence separator can now be configured to something other than "--".
- New option to pass arguments to
FriendlyId::SlugString#approximate_ascii!
, allowing custom approximations specific to German or Spanish. - FriendlyId now queries against the cached_slug column, which improves performance.
- FriendlyId::SlugString class added, allowing finer-grained control over Unicode friendly_id strings.
- FriendlyId::Configuration class added, offering more flexible/hackable options.
- FriendlyId now raises subclasses of FriendlyId::SlugGenerationError depending on the error context.
- Simple models now correctly validate friendly_id length.
- Passing block into FriendlyId deprecated in favor of overriding
the model's
normalize_friendly_id
method. - Updating only the model's scope now also updates the slug.
- Major refactorings, cleanups and deprecations en route to the 3.0 release.
- Fixed typo in Rake tasks which caused delete_old_slugs to fail. (Diego R.V.)
- Made cached_slug automagic configuration occur outside of has_friendly_id. This was causing problems in code where the class is loaded before ActiveRecord has established its connection.
- Fixes for scope feature with Postgres (Ben Woosley)
- Migrated away from Hoe/Newgem for gem management.
- Made tests database-agnostic (Ben Woosley)
- Fixed typo in config options (Steven Noble).
- Fixed typo in post-install message.
- Fixed some issues with gem load order under 1.8.x (closes GH Issue #20)
- Made sure friendly_id generator makes a lib/tasks directory (Josh Nichols)
- Finders now accept instances of ActiveRecord::Base, matching AR's behavior (Josh Nichols)
- SlugGenerationError now raise when a blank value is passed to strip_diacritics
- Fixed Rake tasks creating duplicate slugs and not properly clearing cached slugs (closes GH issues #14 and #15)
- slug cache now properly caches the slug sequence (closes GH issue #10)
- attr_protected is now only invoked on the cached_slug column if attr_accessible has not already been invoked. (closes GH issue #11)
- Added slug caching, offers huge performance boost (Bruno Michel)
- Handle Unicode string length correctly (Mikhail Shirkov)
- Remove alias_method_chain in favor of super (Diego Carrion)
- Fixed upgrade generator not installing rake tasks (Harry Love)
- Fixed handling of very large id's (Nathan Phelps)
- Fixed long index name on migration (Rob Ingram)
- Always call #to_s on slug_text to allow objects such as DateTimes to be used for the friendly_id text. (reported by Jon Ng)
- Non-slugged models now validate the friendly_id on save as well as create (Joe Van Dyk).
- Replaced Shoulda with Contest.
- Fixed bug with find_some; if a record has old slugs, find_some will no longer return multiple copies of that record when finding by numerical ID. (Steve Luscher)
- Fixed bug with find_some: you can now find_some with an array of numerical IDs without an error being thrown. (Steve Luscher)
- Ruby 1.9 compatibility.
- Removed dependency on ancient Unicode gem.
- You can now pass in your own custom slug generation blocks while setting up friendly_id.
- Fixed to_param returning an empty string for non-slugged models with a null friendly_id.
- Made FriendlyId depend only on ActiveRecord. It should now be possible to use FriendlyId with Camping or any other codebase that uses AR.
- Overhauled creaky testing setup and switched to Shoulda.
- Made reserved words work for non-slugged models.
- Fix infinite redirect bug when using .has_better_id? in your controllers (Sean Abrahams)
- Support for scoped slugs (Norman Clarke)
- Support for UTF-8 friendly_ids (Norman Clarke)
- Can now be installed via Ruby Gems, or as a Rails plugin (Norman Clarke)
- Improved handling of non-unique slugs (Norman Clarke and Adrian Mugnolo)
- Shoulda macro (Josh Nichols)
- Various small bugfixes, cleanups and refactorings
- Fixed bug that may return invalid records having similar id/names and using MySQL. (Emilio Tagua)
- Fixed slug generation to increment only numeric extension without modifying the name on duplicated slugs. (Emilio Tagua)
- Fixed compatibility with Rails 2.0.x. (Norman Clarke)
- friendly_id::make_slugs update records in chunks of 1000 to avoid running out of memory with large datasets. (Tim Kadom)
- Fixed logic error with slug name collisions. Thanks to Tim Kadom for reporting this bug.
- Reverted use of UTF8Handler - was causing errors for some people (Bence Nagy)
- Corrected find in case if a friendly_id begins with number (Bence Nagy)
- Added ability to reserve words from slugs (Adam Cigánek)
- Moved "require"" for iconv to init.rb (Florian Aßmann)
- Removed "require" for Unicode, use Rails' handler instead (Florian Aßmann)
- Replaced some magic numbers with constants (Florian Aßmann)
- Don't overwrite find, alias_method_chain find_one and find_some instead (Florian Aßmann)
- Slugs behave more like ids now (Florian Aßmann)
- Can find by mixture of ids and slugs (Florian Aßmann)
- Reformatted code and comments (Florian Aßmann)
- Added support for Edge Rails' Inflector::parameterize (Norman Clarke)
-
Moved strip_diacritics into Slug for easier reuse/better organization.
-
Put class methods inside class << self block. (Norman Clarke)
-
Small change to allow friendly_id to work better with STI. (David Ramalho)
- Improved slug generation for friendly id's with apostrophes. (Alistair Holt)
- Added support for namespaced models in Rakefile. (David Ramalho)
- Cached most recent slug to improve performance (Emilio Tagua).
- Added ability to find friendly_ids by array (Emilio Tagua)
- Made friendly_id raise an error if slug method returns a blank value.
- Added experimental Github gemspec.
- Improved slug name collision avoidance.
- Added :dependent => :destroy to slug relation, as suggested by Emilio Tagua.
- Fixed error when renaming a slugged item back to a previously used name.
- Incorporated documentation changes suggested by Jesse Crouch and Chris Nolan.
- Applied patches from blog commenter "suntzu" to fix problem with model values were being overwritten.
- Applied patch from Dan Blue to make friendly_id no longer ignore options on ActiveRecordBase#find.
- Added call to options.assert_valid_keys in has_friendly_id. Thanks to W. Andrew Loe III for pointing out that this was missing.