FIX: You shouldn't be able to add a parent to Uncategorized

This commit is contained in:
Robin Ward
2014-07-15 15:19:17 -04:00
parent 6d7531f690
commit c6df00a5cc
6 changed files with 45 additions and 15 deletions

View File

@@ -0,0 +1,11 @@
class RemoveUncategorizedParents < ActiveRecord::Migration
def up
uncat = execute("SELECT value FROM site_settings WHERE name = 'uncategorized_category_id'")
if uncat && uncat[0] && uncat[0]['value']
execute "UPDATE categories SET parent_category_id = NULL where id = #{uncat[0]['value'].to_i}"
end
end
def down
end
end