あきくもちゃのブック
(139 keywords)

秋雲茶のお気に入り

  • 里香のブック 里香のブック
  • gacky's report gacky's report
  • マインディアからのお知らせ マインディアからのお知らせ
  • shinout.knowledge shinout.knowledge

あきくもちゃのブックのメンバー

  • 西小倉パンデイロ 西小倉パンデイロ
  • 里香 里香
  • しん しん
  • なおき なおき

rails-rescueの履歴

今、使っている例は、トランザクションを利用した時だけ。

hoge = Hoge.new(x)
Hoge.transaction do
  begin
    hoge.save!
  rescue => ex
    puts ex
  end
end


または、

hoge = Hoge.new(x)
Hoge.transaction do
  if hoge.save
    puts 'succeded'
  else
    raise
  end
end
rescue => ex
  puts ex
end

* このrescue の書き方ができるのかは未検証