Good notes posted by ssoroka
RSS feed
3 thanks
Catching and throwing -- don't!
@wiseleyb and @glosakti, neither of your suggestions are necessary, and both are bad practices.
This test:
test "transactions" do assert_raises ZeroDivisionError do User.transaction do 1/0 end end end
passes just fine on its own, with the transaction rolled back as you’d expect. No need to hack something ugly together.

7 thanks
use raw() instead
Don’t use this method unless you’re sure your string isn’t nil. Instead use the raw() method, which wont raise an exception on nil.

12 thanks
needs to be paired with respond_to
Needs to be paired with respond_to at the top of your class.
class MyController < ApplicationController respond_to :js, :html