Skip to content

null attributes serialized to "null" string #364

codyfauser opened this Issue Mar 23, 2012 · 2 comments

4 participants


Example code:

class Shopify.EmailTemplate extends Shopify.Model
  @persist Shopify.APIStorage
  @encode 'body', 'body_html', 'include_html', 'name', 'title'

  preview: ->
    new Batman.Request
      url: "/admin/email_templates/preview_copy.json"
      method: "post"
        email_template: @toJSON()

Object constructed server side:

#<EmailTemplate id: nil, name: "Order Confirmation", body_html: "null">


It seems that the null value is propagated correctly through Batman, and then gets encoded to "foo=bar&baz=null" by the jQuery.ajax code.

$.param({foo: null}) => "foo=null"
$.param({foo: ""}) => "foo="

See this jQuery bug


OK, I just saw this commit that should have fixed it as long as you source the solo or rails extras... 7913db6

@airhorns airhorns closed this in 201c47f May 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.