Skip to content

Instantly share code, notes, and snippets.

@ahhqx
ahhqx / comments.md
Created August 2, 2011 04:32
Rails 3.0.9 model/controller ready to use with Backbonejs

Do not include root in json

Add ActiveRecord::Base.include_root_in_json = false in an initializer (or config/environment.rb)

Model

Model should use attr_accessible in order to filter the parameter correctly In the example we use the model Task which only accessible attribute : name

@ded
ded / domready.js
Created February 24, 2011 08:46
Smallest x-browser DOM Ready, ever
function r(f){/in/(document.readyState)?setTimeout(r,9,f):f()}
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}