Skip to content

Commit

Permalink
Updated docs with STI info
Browse files Browse the repository at this point in the history
  • Loading branch information
norman committed Mar 13, 2012
1 parent a0cdfd9 commit 997cbf8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Guide.rdoc
Expand Up @@ -241,6 +241,20 @@ This functionality was in fact taken from earlier versions of FriendlyId.

==== Gotchas: Common Problems

===== STI (Single Table Inheritance)

Note that when using FriendlyId with STI classes, you must invoke
{FriendlyId::Base#friendly_id friendly_id} in child classes as well as the parent:

class Foo < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: :slugged
end

class Base < Foo
friendly_id :name, use: :slugged
end

===== Slugs That Begin With Numbers

Ruby's `to_i` function casts strings to integers in such a way that +23abc.to_i+
Expand Down
14 changes: 14 additions & 0 deletions lib/friendly_id/slugged.rb
Expand Up @@ -160,6 +160,20 @@ def should_generate_new_friendly_id?
==== Gotchas: Common Problems
===== STI (Single Table Inheritance)
Note that when using FriendlyId with STI classes, you must invoke
{FriendlyId::Base#friendly_id friendly_id} in child classes as well as the parent:
class Foo < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: :slugged
end
class Base < Foo
friendly_id :name, use: :slugged
end
===== Slugs That Begin With Numbers
Ruby's `to_i` function casts strings to integers in such a way that +23abc.to_i+
Expand Down

0 comments on commit 997cbf8

Please sign in to comment.