title: Ruby: check for nil in javascript
body: <p>I've got a <code>getJSON</code> script that should respond if a Ruby value is not <code>nil</code>, but I'm not sure how to check for <code>if not (ruby's version of) nil</code> through javascript. So far it looks like this:</p>
  
  <pre><code>$.getJSON("&lt;%= xhr_document_path(document) %&gt;", function(d) {
      if (d.ok) {
          $('#modal_&lt;%= document.id %&gt;').modal('show');
          clearInterval(doc_modal_&lt;%= document.id %&gt;);
      } else if (d.error != '') {
          window.location.href = "&lt;%= error_document_path(document) %&gt;";
      }
  });
  </code></pre>
  
  <p>But the <code>else if</code> condition is tripped when the value is nil. How do I check for <code>not nil</code> here?</p>