OSDN Git Service

テスト環境で失敗したため再修正
authorTaro Matsuzawa <tmatsuzawa@kbmj.com>
Mon, 9 Aug 2010 09:28:50 +0000 (18:28 +0900)
committerTaro Matsuzawa <tmatsuzawa@kbmj.com>
Mon, 9 Aug 2010 09:28:50 +0000 (18:28 +0900)
db/migrate/20100809091847_add_retailer_if_dont_have_retailer.rb

index 572440a..cdfc322 100644 (file)
@@ -1,11 +1,14 @@
 class AddRetailerIfDontHaveRetailer < ActiveRecord::Migration
   def self.up
-    r = Retailer.find(1)
-    unless r
+    begin
+      r = Retailer.find(1)
+    rescue ActiveRecord::RecordNotFound
       r = Retailer.new
       r.id = 1
       r.name = "メイン販売元"
       r.save!
+    rescue
+      raise ActiveRecord::RecordNotFound
     end
   end