Skip to content

Instantly share code, notes, and snippets.

@maetl
Created September 3, 2013 11:03
Show Gist options
  • Select an option

  • Save maetl/6422464 to your computer and use it in GitHub Desktop.

Select an option

Save maetl/6422464 to your computer and use it in GitHub Desktop.
Mozart models in raw JS... can they work?
var Geography;
window.Geography = this.Geography = Geography = {};
Geography.Country = Mozart.Model.create({
modelName: "Country"
});
Geography.Country.attributes({
name: "string",
code: "string"
});
Geography.State = Mozart.Model.create({
modelName: "State"
});
Geography.State.attributes({
name: "string",
country_id: "integer",
code: "string"
});
Geography.Country.hasMany(Geography.State, "states");
Geography.Country.ajax({
url: "/admin/countries"
});
Geography.State.ajax({
url: "/admin/states"
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment