You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
Two ways for testing preloading/eager-loading of ActiveRecord associations in Rails … and check why 5600+ Rails engineers read also this Two ways for testing preloading/eager-loading of ActiveRecord associations in Rails As a developer who cares about performance you know to avoid N+1 queries by using #includes, #preload or #eager_load methods . But is there a way of checking out that you are doin
Railsアプリで、ActiveRecord::Base.transactionを使って、 トランザクションを明示的に張り、異常がある場合にロールバックする、 という実装は大いに有りますよね。 僕はRSpecを使ってテストしています。 RSpecを使って、DBがロールバックされることを確認する方法を書いておきます。 例えば、コントローラに次のような処理を書いたとします。 モデルの変更後、メールを送信する、という処理で、ここでは、メールの送信に失敗した場合は、 変更をロールバックする、という仕様とします。(その仕様は果たして妥当か?はここでは考えない。) def save_and_send_mail(model) begin ActiveRecord::Base.tansaction do model.save! SomeMailer.something.deliver end rescue
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く