Skip to content

Instantly share code, notes, and snippets.

finishedMaterializing: function(manager) {
var isDirty = get(manager, 'dirtyWhileMaterializing');
if (isDirty) {
manager.transitionTo('loaded.updated');
set(manager, 'dirtyWhileMaterializing', false);
} else {
manager.transitionTo('loaded.saved');
}
},
App.User = DS.Model
settings: DS.belongsTo App.UserSettings
App.UserSettings = DS.Model
friends: DS.HasMany App.Friend
Adapter.map App.User
settings: {embedded: true}
@igorT
igorT / gist:1342805
Created November 6, 2011 12:23 — forked from mattheworiordan/gist:1037984
Backbone patch to defer update method requests when new create requests are not complete on a model
(function() {
function proxyAjaxEvent(event, options, dit) {
var eventCallback = options[event];
options[event] = function() {
// check if callback for event exists and if so pass on request
if (eventCallback) { eventCallback(arguments[ 0], arguments[ 2 ]); }
dit.processQueue(); // move onto next save request in the queue
}
}
Backbone.Model.prototype._save = Backbone.Model.prototype.save;
class Location < ActiveRecord::Base¬
▸ has_many :location_images, :dependent => :destroy¬
▸ has_friendly_id :name, :use_slug => true¬
▸ attr_accessible :cached_slug, :name, :description, :location_images_attributes¬
¬
▸ accepts_nested_attributes_for :location_images, :reject_if => lambda { |t| t['location_image'].nil? }¬
¬
end¬
{"utf8"=>"✓",
"authenticity_token"=>"uHqp3TSCzTpfjnMX+vJ/6vIIcaJaYP7JT0Qor5wYAxs=",
"location"=>{"name"=>"hhuih",
"cached_slug"=>"",
"description"=>"bhkhk",
"location_images_attributes"=>{"0"=>{"caption"=>"safs",
"photo"=>#<ActionDispatch::Http::UploadedFile:0x00000003c375c8 @original_filename="sshot1.png",
@content_type="image/png",
@headers="Content-Disposition: form-data; name=\"location[location_images_attributes][0][photo]\"; filename=\"sshot1.png\"\r\nContent-Type: image/png\r\n",
@tempfile=#<File:/tmp/RackMultipart20110725-27866-f7hzdx>>},
# GET /locations/new¬
# GET /locations/new.xml¬
def new¬
@location = Location.new¬
3.times {@location.location_images.build} ¬
respond_to do |format|¬
format.html # new.html.erb¬
format.xml { render :xml => @location }¬
end¬
end¬