Skip to content

Instantly share code, notes, and snippets.

@boy-jer
boy-jer / multi-parameter_attributes_spec.rb
Created December 4, 2013 10:59 — forked from k-rudy/multi-parameter_attributes_spec.rb
Multiparameter Attributes support in Mongoid 4 (Rails 4.0.1) Code is taken from https://github.com/mongoid/mongoid/issues/2954 with minor amendments to work with Rails 4.0.1
# This class is needed since Mongoid doesn't support Multi-parameter
# attributes in version 4.0 before it's moved to active model in rails 4
#
# https://github.com/mongoid/mongoid/issues/2954
#
require "spec_helper"
require 'mongoid/multi_parameter_attributes'
describe Mongoid::MultiParameterAttributes do
module Mongoid
module ActiveRecord
module EagerLoadable
module Criteria
extend ActiveSupport::Concern
def includes_active_record(*relations)
relations.each do |relation|
metadata = RelationMetadata.new(relation)
@boy-jer
boy-jer / animations-router-stuff.coffee
Created July 18, 2013 09:39 — forked from ebryn/animations-router-stuff.coffee
animations in emberjs router
App.Router.map ->
@route "a"
@route "b"
@route "ab"
@route "ba"
App.ARoute = Em.Route.extend
events:
animateToB: ->
@transitionTo('ab')
@boy-jer
boy-jer / S3Upload.js
Created July 18, 2013 09:37 — forked from raytiley/S3Upload.js
This class uploads to an S3 bucket. And was adapted from this blog post: http://www.ioncannon.net/programming/1539/direct-browser-uploading-amazon-s3-cors-fileapi-xhr2-and-signed-puts/ You need to have an endpoint on your server that will sign your S3 request for you ('covered in the plog post'). To use: App.S3Upload.create({ file: file-from-fil…
App.S3Upload = Ember.Object.extend({
progress: 0,
state: "pending",
bucket: 'your-bucket'
complete: false,
s3url: null,
xhr: null,
file: null,
fileName: function() {
var file = this.get('file');
#!/usr/bin/env ruby
require 'curb'
require 'yaml'
hosts = %w(
example.com
google.com
)

Using Yo Ember instead of Ember-Rails

First Generate Ember application using Yo Ember generator

  1. Install yeoman npm install -g yo grunt-cli bower
  2. Install ember-generator npm install -g generator-ember
  3. Create your project mkdir webapp && cd webapp
  4. Generate ember template yo ember
  5. Run itgrunt server
// store.js
App.Adapter = DS.RESTAdapter.reopen({
bulkCommit: false,
url: 'http://localhost:5000',
namespace: 'api',
corsWithCredentials: true,
headers: {
'Accept': 'application/vnd.vendor+json;version=1',
'Content-type': 'application/json',
// store.js
var serializer = DS.RESTSerializer.create();
App.Adapter = DS.RESTAdapter.reopen({
bulkCommit: false,
serializer: serializer,
});
serializer.configure({
{{view Ember.TextField
valueBinding="storeCard.relevantDate"
classNames="timepicker-default input-small"
}}
<span class='add-on'><i class="icon-time"></i></span>

I've been trying to do routing in Ember using something other than id. This is how I implemted a dasherized version of a post's title. I get the feeling that instead of the deserialize function I should be overwrite the model function as the guides suggest, but then I lose the symmetry I have with the serialize function.

If there's a better/more ember way, I'd love to know.

Thanks @darthdeus for teaching me about DS.LoadPromise