public
Rubygem
Description: FriendlyId is the “Swiss Army bulldozer” of slugging and permalink plugins for ActiveRecord. It allows you to create pretty URL’s and work with human-friendly strings as if they were numeric ids for ActiveRecord models.
Homepage: http://friendly-id.rubyforge.org
Clone URL: git://github.com/norman/friendly_id.git
More README tweaking.
norman (author)
Wed Oct 22 09:36:41 -0700 2008
commit  89601d10ba528cdbae18688affe0314dfe0e5381
tree    bcb5877f72433d2d233dede0d25326f9c12e73ab
parent  869da046279a5916223cd0be2873de1bfb56e594
...
123
124
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
127
128
...
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
...
185
186
187
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
189
190
0
@@ -123,6 +123,35 @@ only for languages that use some variant of the Roman alphabet.
0
 
0
 You must install the "unicode" and "iconv" to use this feature.
0
 
0
+h3. This is all too complicated. Why not just override to_param to return the
0
+id followed by a dasherized string?
0
+
0
+This creates URL's like the following:
0
+
0
+  http://www.example.org/profiles/12-joe
0
+
0
+Which works great. But at times you may prefer not having the id in the URL.
0
+
0
+  http://www.example.org/profiles/joe
0
+  
0
+Note that if you are using the to_param trick for URL's, you should check to
0
+make sure your URL's are being accessed with the most up-to-date slug, because
0
+the following two URL's will point to the same content:
0
+
0
+  http://www.example.org/posts/12-i-love-friend-id
0
+  http://www.example.org/profiles/12-friendly-id-sucks
0
+
0
+In these cases it's convenient to have a before_filter in your controller
0
+that does something like this:
0
+
0
+  def ensure_current_url
0
+    if request.headers['REQUEST_URI'] != post_path(@post)
0
+      redirect_to @post, :status => :moved_permanently
0
+    end  
0
+  end
0
+
0
+
0
+
0
 h2. Getting it
0
 
0
 Git repository: git://github.com/norman/friendly_id.git
0
@@ -156,33 +185,6 @@ The default is to remove dead slugs older than 45 days, but is configurable:
0
 
0
 rake:friendly_id:remove_old_slugs MODEL=MyModelName DAYS=60
0
 
0
-h2. This is all too complicated. Why not just override to_param to return the
0
-id followed by a dasherized string?
0
-
0
-This create URL's like the following:
0
-
0
-  http://www.example.org/profiles/12-joe
0
-
0
-Which works great. But at times you may prefer not having the id in the URL.
0
-
0
-  http://www.example.org/profiles/joe
0
-  
0
-Note that if you are using the to_param trick for URL's, you should check to
0
-make sure your URL's are being accessed with the most up-to-date slug, because
0
-the following two URL's will point to the same content:
0
-
0
-  http://www.example.org/posts/12-i-love-friend-id
0
-  http://www.example.org/profiles/12-friendly-id-sucks
0
-
0
-In these cases it's convenient to have a before_filter in your controller
0
-that does something like this:
0
-
0
-  def ensure_current_url
0
-    if request.headers['REQUEST_URI'] != post_path(@post)
0
-      redirect_to @post, :status => :moved_permanently
0
-    end  
0
-  end
0
-
0
 h2. Bugs:
0
 
0
 Please report them on "Lighthouse":http://randomba.lighthouseapp.com/projects/14675-friendly_id.

Comments