Permalink
Browse files

Updated docs with STI info

  • Loading branch information...
1 parent a0cdfd9 commit 997cbf8c90adad023f5c053a9433e6e1b30d3874 @norman norman committed Mar 13, 2012
Showing with 28 additions and 0 deletions.
  1. +14 −0 Guide.rdoc
  2. +14 −0 lib/friendly_id/slugged.rb
View
14 Guide.rdoc
@@ -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+
View
14 lib/friendly_id/slugged.rb
@@ -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+

0 comments on commit 997cbf8

Please sign in to comment.