ember.js

Convert base64 image to StringIO for Carrierwave

六眼飞鱼酱① 提交于 2019-12-20 10:55:30
问题 I am hoping someone can help me understand this. I have a base64 string for an image: "data:image/jpeg;base64,/9j/4AAQSkZJRgABA..." I would like to send it using ember's createRecord and commit(): this.get('store').createRecord(Emb.Painting, {name: newName, image: newImage}); Then I want to convert it to StringIO for carrierwave and save it: StringIO.class_eval { def original_filename; "stringiohaxx.jpg"; end } io = StringIO.new(Base64.decode64(params[:painting][:image])) @painting = Painting

Ember Handlebars Templates in <head> tag

戏子无情 提交于 2019-12-20 10:55:11
问题 Is it possible for ember (specifically the application template) to operate inside the head tag in order to dynamically change things like the title tag, meta tags, external css stylesheets and the favicon? If so, what would be a clean way of doing this? 回答1: In order to make this work, what I did was I created handlebar helpers. For Example, If you want to change the title for views which is very common, here is the helper. Ember.Handlebars.helper('headTitle', function(title) { Ember.$('head

What is the difference between the '[]' property and the '@each' property in ember.js?

房东的猫 提交于 2019-12-20 10:27:12
问题 I've noticed that the enumerable mixin has computed properties that depends on the '[]' property, while ember arrays also have the '@each' property. What is the difference between depending on '[]' and '@each' ? My vague understanding (correct me if I'm wrong) is that '[]' is triggered when the array content is replaced. But is this different than depending on the property itself? Consider the the following class: C = Ember.Object.extend({ things: null, watcher1: (function() { console.log(

Asset pipeline for Ember.js, Express.js and Node.js?

☆樱花仙子☆ 提交于 2019-12-20 10:19:06
问题 I'm building an Ember.js application using Express.js as the backend. Right now, I load all my *.js files individually and store my Handlebars templates in my HTML file. I like to replace with a full-fledged "asset pipline" similar to the one in Rails. In a perfect world, this would support: Convert CoffeeScript to JavaScript. Pre-compile Handlebars templates using the Ember.js extensions. Concatenate and minify JavaScript and CSS (production only). I've looked briefly at Require.js, connect

In latest Ember, how do you link to a route with just the id/name of a model, rather than providing all of its attributes in the linking page?

有些话、适合烂在心里 提交于 2019-12-20 09:56:00
问题 I ran into a problem when converting from Ember 1.0-pre2 to latest master (43354a98) and the new router, namely-- If I have a route which loads just the name and ID for a bunch of records, and tries to link each of those records to another route which should display the full model, when I arrive at the new route, the new model is never loaded, and name and ID are the only attributes that are available. Example code: App.Router.map(function() { this.route("index"); this.resource("birds"); this

How to debug ember-cli tests running in phantomjs

眉间皱痕 提交于 2019-12-20 09:46:08
问题 Context: I have an acceptance test for my ember-cli application, and the test passes just fine in Chrome. However, in phantomjs, my test fails -- the UI doesn't get created the same way, and I'm trying to work out why. (I think the test is broken because of https://github.com/ember-cli/ember-cli/issues/1763, but the general question of how to debug remains) In Chrome, I can use the standard debugging tools on my tests and all is well -- but in phantomjs, I can't get at it with a debugger. I

Ember Router - How to handle 404 (Not Found) routes?

拈花ヽ惹草 提交于 2019-12-20 09:38:08
问题 I'm trying to figure out how to handle invalid routes within my application using Ember.Router . Currently if I enter an invalid route, e.g. myapp.com/#FooBarDoesntExist, it will redirect to the index route ('/'). I'd like it if I could define a notFound or 404 state that it would route to so I can inform the user what happend. As opposed to them getting dumped on the home page. 回答1: Ember.Router in its current version does not provide means to handle unknown routes. Time to hack! Solution 1

How to use HTML5 Local Storage with Ember.js?

旧街凉风 提交于 2019-12-20 09:04:08
问题 I would like to use HTML5 Local Storage with my Ember.js. I haven't been able to find any examples of doing this without Ember Data. How should this be done? What do I need to consider? 回答1: So let's say we have an object called Storage that in our real-world implementation would represent an adapter-like object for the localStorage to store and retrieve data: App.Storage = Ember.Object.extend({ init: function() { this.clearStorage(); var items = ['foo', 'bar', 'baz']; localStorage.items =

How to mock an Ember-CLI service in an acceptance test?

耗尽温柔 提交于 2019-12-20 08:56:44
问题 Quick summary/tldr: It seems that Ember's container lookup process + Ember-CLI's module resolver doesn't allow manually un-registering a service and then registering a replacement if the original service can be resolved using the resolver (I want to do the method described here, but it doesn't work) How can I mock an Ember-CLI service in an acceptance test without using a hacky, custom resolver? (example project/acceptance test here) Detailed explanation + example Create a new service that is

Architecture for data layer that uses both localStorage and a REST remote server

馋奶兔 提交于 2019-12-20 08:56:22
问题 Anybody has any ideas or references on how to implement a data persistence layer that uses both a localStorage and a REST remote storage: The data of a certain client is stored with localStorage (using an ember-data indexedDB adapter). The locally stored data is synced with the remote server (using ember-data RESTadapter). The server gathers all data from clients. Using mathematical sets notation: Server = Client1 ∪ Client2 ∪ ... ∪ ClientN where, in general, any record may not be unique to a