justinweiss/reactive_resource — pull request #8 by cdmicacc (2013-04-17 18:38:33+00:00)
Title: Gracefully handle attributes = nil on construction

This is actually also a bug in ActiveResource, but exists here too: If you do something like

@user = User.new(params[:user])

but params[:user] is not set (is nil, e.g because the user reloaded the page you POSTed to), you'll get an ugly error coming from reactive_resource:

NoMethodError (undefined method `stringify_keys' for nil:NilClass):
app/controllers/users_controller.rb:13:in `new'
app/controllers/users_controller.rb:13:in `create'

Given that e.g. ActiveRecord handles this case nicely, I have made a simple change that lets reactive_resource do likewise.