Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated docs with STI info

  • Loading branch information...
commit 997cbf8c90adad023f5c053a9433e6e1b30d3874 1 parent a0cdfd9
Norman Clarke authored
14  Guide.rdoc
Source Rendered
@@ -241,6 +241,20 @@ This functionality was in fact taken from earlier versions of FriendlyId.
241 241
 
242 242
 ==== Gotchas: Common Problems
243 243
 
  244
+===== STI (Single Table Inheritance)
  245
+
  246
+Note that when using FriendlyId with STI classes, you must invoke
  247
+{FriendlyId::Base#friendly_id friendly_id} in child classes as well as the parent:
  248
+
  249
+  class Foo < ActiveRecord::Base
  250
+    extend FriendlyId
  251
+    friendly_id :name, use: :slugged
  252
+  end
  253
+
  254
+  class Base < Foo
  255
+    friendly_id :name, use: :slugged
  256
+  end
  257
+
244 258
 ===== Slugs That Begin With Numbers
245 259
 
246 260
 Ruby's `to_i` function casts strings to integers in such a way that +23abc.to_i+
14  lib/friendly_id/slugged.rb
@@ -160,6 +160,20 @@ def should_generate_new_friendly_id?
160 160
 
161 161
 ==== Gotchas: Common Problems
162 162
 
  163
+===== STI (Single Table Inheritance)
  164
+
  165
+Note that when using FriendlyId with STI classes, you must invoke
  166
+{FriendlyId::Base#friendly_id friendly_id} in child classes as well as the parent:
  167
+
  168
+  class Foo < ActiveRecord::Base
  169
+    extend FriendlyId
  170
+    friendly_id :name, use: :slugged
  171
+  end
  172
+
  173
+  class Base < Foo
  174
+    friendly_id :name, use: :slugged
  175
+  end
  176
+
163 177
 ===== Slugs That Begin With Numbers
164 178
 
165 179
 Ruby's `to_i` function casts strings to integers in such a way that +23abc.to_i+

0 notes on commit 997cbf8

Please sign in to comment.
Something went wrong with that request. Please try again.