Skip to content

Instantly share code, notes, and snippets.

@Unnumbered
Unnumbered / rename_collection.rb
Created March 17, 2017 09:40
how to rename mongodb collection with mongoid 5.x
def rename_collection(old_name, new_name, drop_target=false)
client = Mongoid::Clients.default
current_db = client.database
admin_db = Mongo::Database.new(client, Mongo::Database::ADMIN, current_db.options)
admin_db.command(renameCollection: "#{current_db.name}.#{old_name}",
to: "#{current_db.name}.#{new_name}",
dropTarget: drop_target)
end
@Unnumbered
Unnumbered / item-form.coffee
Created March 30, 2017 13:53
nested errors workaround
_embeddedErrorsHandling: Ember.observer 'item.errors.[]', ->
@get('item.errors.content').forEach (error) =>
if error.attribute.indexOf('target_bid.') == 0
attribute = Ember.String.camelize(error.attribute.replace('target_bid.', ''))
@get('item.targetBid.errors').add(attribute, error.message)
@set('item.targetBid.isError', true)
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['dropdown-container-content']
});
Build failed.
The Broccoli Plugin: [Fingerprint] failed with:
SyntaxError: Unexpected token: name (o)
at JS_Parse_Error.get (eval at <anonymous> (/home/andrey/thewaay/front-theewaay-backend/node_modules/uglify-js/tools/node.js:27:1), <anonymous>:86:23)
at new BroccoliBuildError (/home/andrey/thewaay/front-theewaay-backend/node_modules/broccoli-builder/lib/broccoli-build-error.js:18:29)
at /home/andrey/thewaay/front-theewaay-backend/node_modules/broccoli-builder/lib/builder.js:168:19
at tryCatch (/home/andrey/thewaay/front-theewaay-backend/node_modules/rsvp/dist/rsvp.js:525:12)
at invokeCallback (/home/andrey/thewaay/front-theewaay-backend/node_modules/rsvp/dist/rsvp.js:538:13)
at publish (/home/andrey/thewaay/front-theewaay-backend/node_modules/rsvp/dist/rsvp.js:508:7)
at publishRejection (/home/andrey/thewaay/front-theewaay-backend/node_modules/rsvp/dist/rsvp.js:443:3)