-
Rails’ and Ruby’s Hash transform_values
Rails: 4.2.1-5.2.3 and Ruby >= 2.5.5 have a transform_values method on Hash that allows you to pass a block to the method and transform the values of the key-value map in the hash based on the block contents. Essentially, it’s map but for the Hash values only, and with no weird Hash/array-element syntax. From the…
-
XML Handler Bypassing ParseError Handling Rack Middleware on Rails 6
In a project using actionpack-xml_parser, and implementing a modified version of Catching Invalid JSON Parse Errors with Rack Middleware to also handle XML errors, an upgrade to Rails 6 broke the handling of the ParseError. Interestingly enough, JSON was being handled as expected. TL;DR: The short answer to this is that config/initializers/wrap_parameters.rb only had json…
-
rspec-rails tricks: Hacking Your Routes for a Spec
I don’t know that this is so much a reminder of “What can be done with rspec-rails” as a note that, “If you do this will rspec-rails, you will also need to undo it.” Today’s note: If you hack the application routes for a controller test, you have to reload routes. The original problem This…