Created
April 27, 2012 07:41
-
-
Save sdepold/2507049 to your computer and use it in GitHub Desktop.
category migration script cc @sdepold
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "!! unique-ifying category names" | |
mk_unique = lambda{ |c| c.update_attribute(:name, c.name + rand(8**16).to_s(36)); print "." } | |
Category.all.each{ |c| mk_unique[c] if c.name.empty? || (Category.find_all_by_name(c.name).size > 1) }; nil | |
puts "\n\n!! migrating gettext keys" | |
mk_migrate = lambda{ |c, gk| gk.update_attribute(:accesskey, "category.#{c.name.to_slug}"); print "." } | |
Category.all.each{ |c| (gk = GettextKey.find_by_accesskey("category.#{c.id}")) ? mk_migrate[c, gk] : print("X") }; nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment