Nick,

I agree it's too simple to hide or rely on a plugin. Thanks for the code!

Scott


At 02:52 PM 12/29/2009, you wrote:
>Hi Scott,
>
>So it sounds like your question is two parts: 
>first, generating the slugs themselves, and 
>second, updating all the existing records.
>
>As to the first, there are plenty of plugins and 
>strategies for generating the slugs. Perhaps 
>you've already got that taken care of. I 
>personally wouldn't use a plugin for this – the 
>logic is just too simple for me to want to hide 
>it away. A before_create to call an instance 
>method that invokes SecureRandom.hex is about as complicated as it needs to be.
>
>Just make sure you have a simple test for uniqueness :)
>
>Whether or not you call that from a Rake task, 
>or in a loop directly after the migration that 
>adds the column, is up to you. I would 
>personally lean toward updating the existing 
>records in the migration itself. And, speaking 
>of the migration, do remember that you'll want 
>to index your table on the new column.
>
>This all might be a bit more succinctly 
>expressed in code: <http://gist.github.com/265675>http://gist.github.com/265675
>
>All of this to say, I suppose, that I don't have 
>any particularly better suggestion. My 
>suggestions here are basically just iterative on 
>what it sounds like you're already doing.
>
>--
>Nick Zadrozny
>
>--
>SD Ruby mailing list
>[email protected]
><http://groups.google.com/group/sdruby>http://groups.google.com/group/sdruby

-- 
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby

Reply via email to