Every repository with this icon (
Every repository with this icon (
| 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. edit |
-
"For sluggable models, if such a word is used, it will be treated the same as if that slug was already taken (numeric extension will be appended). Defaults to ["new", "index"]." But when I try to create object with name 'new' I got an exception "The slug text is a reserved value" ??
Comments
-
hi, does anyone use friendly_id with i18n (http://github.com/svenfuchs/rails-i18n) and globalize2 (http://github.com/joshmh/globalize2)?
I'd want multiple url that points to the same resource:
http://mysite.com/it/pages/azienda
http://mysite.com/en/pages/companymaybe I have to translate the slug?
or use the scope?
or add a language attribute to the slug?bye
Devis_
Comments
At the moment friendly_id doesn't have support for anything like that, but I think it's a great idea for a new feature in the next version.
activestylus
Mon Sep 28 10:47:07 -0700 2009
| link
+1 on this - would be awesome to be able to pull it off with vanilla Rails I18n too
I see no reason why any extra dependencies would be necessary; probably all that will be needed is a locale field in the slug table. The query functionality would be very similar to the way scopes are handled.
I'm probably not going to have time to work on this for about 2 more weeks but I'll definitely include it in the next major version.
I've a doubt about the routes implementation:
http://mysite.com/en/pages/company => 200 FOUND
http://mysite.com/en/pages/azienda => 404 NOT FOUND
http://mysite.com/it/pages/company => 404 NOT FOUND
http://mysite.com/it/pages/azienda => 200 FOUND
is it correct, in your opinion?
bye
Devis_
ahah this is much better:
http://mysite.com/en/pages/company => 200 FOUND
http://mysite.com/en/pages/azienda => 301 REDIRECT => http://mysite.com/en/pages/company
http://mysite.com/it/pages/company => 301 REDIRECT => http://mysite.com/it/pages/azienda
http://mysite.com/it/pages/azienda => 200 FOUNDYes, I think that makes good sense.
You could actually have an interesting philosophical discussion about whether the Italian version of a document and the English version are the "same." You could make a case that they are idempotent but not identical. If you believe that, then it may be more proper to do a 303 redirect (see other) rather than a 301 (moved permanently). However, the point is academic and it would likely make no real practical difference.
Regardless, I definitely think a redirect is much better than a 404, because somebody might want to view the English or Italian version of a resource, and try to manually change the IT to an EN or vice versa. Your app should be smart enough to figure out what the person wants.
-
Scope doesn't update when underlying record is changed
2 comments Created 26 days ago by nateabbottSorry for another issue...
When you have a scoped slug, and the name of the scope changes, the slugs are not updated. i.e. I have users and posts, and there's the option :scope => :user. When I change the friendly_id of the user (which is name), the scope of the posts is not updated, and therefore they cannot be found by the find_one method (which is looking for an item with the new scope)
Let me know if you need a more concrete example. Thanks for the help with this awesome gem!
Comments
Thanks, I think your explanation is actually crystal clear. I'll work on a patch for that, but it will likely not be ready today. Probably Thursday or Friday. I have a few other bugs related to scopes to work on, as well as a contributed patch pending, so I'll be doing a small overhaul of the scope features. In the mean time I'd suggest not using cached slugs if this is causing problems for your application, and count on being able to turn them back on by early next week at latest.
nateabbott
Tue Oct 27 08:00:20 -0700 2009
| link
no problem -- thanks again for your work on this!












I think this is an example of DDD ("documentation driven development") gone awry. I probably documented this feature in a branch before adding it, and then ended up implementing it differently. Until now nobody has called me on it, and I never noticed it.
I will get a fix in place soon so that the feature actually matches what it says in the docs.
Thank you! Please write here, when I'll done it so I could update you great plugin.