Skip to content

Instantly share code, notes, and snippets.

# 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¬
{"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>>},
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¬
@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;
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}
finishedMaterializing: function(manager) {
var isDirty = get(manager, 'dirtyWhileMaterializing');
if (isDirty) {
manager.transitionTo('loaded.updated');
set(manager, 'dirtyWhileMaterializing', false);
} else {
manager.transitionTo('loaded.saved');
}
},
Running: {"package":"container"}
Tests timed out
rake aborted!
Command failed with status (124): [phantomjs /home/igor/.rvm/gems/ruby-1.9.2-...]
/home/igor/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.0.4/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
/home/igor/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.0.4/lib/rake/file_utils.rb:45:in `call'
/home/igor/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.0.4/lib/rake/file_utils.rb:45:in `sh'
/home/igor/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.0.4/lib/rake/file_utils_ext.rb:37:in `sh'
/home/igor/.rvm/gems/ruby-1.9.2-p320/bundler/gems/ember-dev-31e82147b572/lib/tasks/test.rake:60:in `block (3 levels) in <top (required)>'
/* Put your CSS here */
html, body {
margin: 20px;
}
App.Person = Ember.Object.extend({
childAges: Ember.computed.mapBy('children', 'age')
});
App.MyRecord = DS.Model.extend({
save: function(){
setSomeFlag();
this._super();
}
})