-
-
Notifications
You must be signed in to change notification settings - Fork 591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
best way to limit slug length? #190
Comments
@bendwoodward http://en.wikipedia.org/wiki/Slug_(production) |
You can just use the regular validations offered by Active Record; i.e. |
The term comes from the typesetting industry. IIRC Moveable Type was the blog engine that first used this term, since they used the typesetting metaphor throughout their software and materials. |
Oh. Just read @myabc's link. I am completely wrong. |
There is an option :max_length in friendly_id 3.x, which truncates slug to max_length. I cannot find anything similar in 4.0, but I think it is very useful option. |
@bhanuprasad143 ActiveSupport provides the
You can also still use Babosa with FriendlyId if you want; that's the slug library extracted from FriendlyId 3, and has all of the string processing options that FriendlyId 3 had, though most of its functionality was incorporated into Rails 3. |
I just added this method to my model: def normalize_friendly_id(string)
super[0..139]
end |
+1 to @Sjors' solution |
|
@norman I think it was adopted by the newspaper industry based on its use in the typesetting industry: https://en.wikipedia.org/wiki/Slug_(typesetting) |
I managed to save an item that has an epically long slug, but now I can't perform CRUD on it via a browser due to ...
What would be the best way to limit the slug's length. Why are they called slugs anyway, yuck.
The text was updated successfully, but these errors were encountered: