From 989a04be979c2be16551c726820af14bdec880f5 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Thu, 26 Sep 2013 17:25:01 -0700 Subject: [PATCH] fixes #1984 --- app/models/pool.rb | 2 +- script/fixes/019_fix_pool_names.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 script/fixes/019_fix_pool_names.rb diff --git a/app/models/pool.rb b/app/models/pool.rb index 307cdfb09..65832f42e 100644 --- a/app/models/pool.rb +++ b/app/models/pool.rb @@ -2,7 +2,7 @@ require 'ostruct' class Pool < ActiveRecord::Base validates_uniqueness_of :name - validates_format_of :name, :with => /\A[^\s,]+\Z/, :on => :create, :message => "cannot have whitespace or commas" + validates_format_of :name, :with => /\A[^\s,]+\Z/, :message => "cannot have whitespace or commas" validates_inclusion_of :category, :in => %w(series collection) belongs_to :creator, :class_name => "User" belongs_to :updater, :class_name => "User" diff --git a/script/fixes/019_fix_pool_names.rb b/script/fixes/019_fix_pool_names.rb new file mode 100644 index 000000000..8f0024da7 --- /dev/null +++ b/script/fixes/019_fix_pool_names.rb @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby + +require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment')) + +ActiveRecord::Base.connection.execute("set statement_timeout = 0") + +Pool.where("name like ?", "%,%").find_each do |pool| + pool.update_attribute(:name, pool.name.gsub(/,/, "_")) +end