This is my upload-file type for what I use at work. We use angular-upload for the upload service to do the actual file uploading. We also have several abstractions and use ES6 that may confuse you a little bit (sorry about that). Hopefully this gets you started though.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -----BEGIN PGP PUBLIC KEY BLOCK----- | |
| Version: GnuPG v1 | |
| mQINBFMgUU0BEAC50m+8R2DVAG6hP9FurOBez+6ebhFWwzLqU5cTmS1jiNJvcQlf | |
| keEhyYvqpncrcxAy+NCa/x1pLBWgOkJ0yEC85CNgLJOvmYj2zBE+y3ZWz9or72bB | |
| KyrhnVkY7L3VE7fX0yhrKTsVrbRal/IRm8T8H2RXAxKnacybqEFksEBkS/lezu6S | |
| EUVrLVJPPkjUWJypIi+4J9/iDtJ2nkblndlfQTxHgOR1xdpDpPIqRLBX0g+ppm2K | |
| jH+LCovln9zKXUaxxLnFZs43XHbiRijsISxHjIVMkY/6c38khX4kFehSJ3LwmTo2 | |
| J5g/GvYhP+IaD5dvQGTuvVOP3El1M0nLGLxNo0tYqgwx7gsWdXLxdxWeJio1Z7Up | |
| sjWxalaX8sEMYiK+JOlzSM5rDWfrvugviRYQyTFj8XrRyVj6EdqJ5v16ofQRw+0+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| DS.attr('object') | |
| */ | |
| App.ObjectTransform = DS.Transform.extend({ | |
| deserialize: function(value) { | |
| if (!$.isPlainObject(value)) { | |
| return {}; | |
| } else { | |
| return value; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // app/transforms/array.js | |
| import Ember from 'ember'; | |
| import DS from 'ember-data'; | |
| export default DS.Transform.extend({ | |
| deserialize: function(value) { | |
| if (Ember.isArray(value)) { | |
| return Ember.A(value); | |
| } else { | |
| return Ember.A(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fda = ( fields ) => { | |
| let data = [] | |
| for(const f of fields ){ | |
| data.push(fd(f)) | |
| } | |
| return data | |
| } | |
| const fd = ( field ) => { | |
| let data = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function removeFirstConnection () { | |
| $('[type=ellipsis-horizontal-icon]').first().click() | |
| setTimeout(() => { | |
| $('.js-mn-connection-card__dropdown-delete-btn > button').click() | |
| setTimeout(() => { | |
| $('[data-control-name="confirm_removed"]').click() | |
| }, 250) | |
| }, 250) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var express = require('express'), | |
| httpProxy = require('http-proxy'), | |
| app = express(); | |
| var proxy = new httpProxy.RoutingProxy(); | |
| function apiProxy(host, port) { | |
| return function(req, res, next) { | |
| if(req.url.match(new RegExp('^\/api\/'))) { | |
| proxy.proxyRequest(req, res, {host: host, port: port}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class User < ActiveRecord::Base | |
| devise :invitable, :database_authenticatable, :registerable, :recoverable, | |
| :rememberable, :confirmable, :validatable, :encryptable | |
| # ... | |
| # devise confirm! method overriden | |
| def confirm! | |
| welcome_message | |
| super |
This is a simplified, but fairly thorough, set of scripts and configuration to enable Heroku Release Phase for Rails apps.
Further, this particular set up plays nicely with Heroku Review Apps in that the release phase script will:
- Fail, loudly, if the DB does not yet exist.
- Load the DB schema if the current schema version (as determined by
bin/rails db:version) is0. - Run DB migrations otherwise.
For a "normal" app that usually means it will run the DB migrations.
OlderNewer