1. 7

  2. 4

    Ouch! The #try! thing in Rails 4 reeks of PHP’s mysql_unescape_real though.

    1. 5


    2. 1

      This is especially frustrating because they changed the behavior of #try in Rails 4.0 and added #try! with the old behavior.

      1. 2

        I thought #try was the same, but they added #try! which would basically do what Avdi was implying #try should already be doing?

        1. 1

          In Rails 3.2.22, #try says:

          Invokes the method identified by the symbol method … just like the regular Ruby Object#send does. Unlike that method however, a NoMethodError exception will not be raised and nil will be returned instead, if the receiving object is a nil object or NilClass.


          But in Rails 4.0.0 it says:

          Invokes the public method whose name goes as first argument just like public_send does, except that if the receiver does not respond to it the call returns nil rather than raising an exception.