How to handle ‘no route matched’ in Ember.js and show 404 page?

App.Router.map(function() { //set up all of your known routes, and then… this.route(“fourOhFour”, { path: “*path”}); }); .. where you have your FourOhFourRoute defined to show the “no route found” message of your choosing. You will be able to access the originally requested path in the fourOhFour route as the path parameter. EDIT: just for clarity … Read more

Ember authentication best practices?

UPDATE: Like @DustMason says in his answer, check out the awesome embercasts for authentication best-practices. Client Side Authentication Part I Client Side Authentication Part II In order to completely separate the view (Ember app) from the server (Rails app) I want to use token authentication. I will likely use Devise on the Rails server. Makes … Read more

EmberJS actions – call one action from another when wrapped within `actions`

You can use the send(actionName, arguments) method. App.IndexController = Ember.ArrayController.extend({ actions: { actionFoo: function() { alert(‘foo’); this.send(‘actionBar’); }, actionBar: function() { alert(‘bar’); } } }); Here is a jsfiddle with this sample http://jsfiddle.net/marciojunior/pxz4y/

emberjs – how to mark active menu item using router infrastructure

Ember 1.11+: {{#link-to “dashboard” tagName=”li”}} <a href=”https://stackoverflow.com/questions/11628489/{{view.href}}”>Dashboard</a> {{/link-to}} Ember < 1.11 (bind-attr required): {{#link-to “dashboard” tagName=”li”}} <a {{bind-attr href=”https://stackoverflow.com/questions/11628489/view.href”}}>Dashboard</a> {{/link-to}}

Check for a value equals to in Ember Handlebar If block helper

The {{#if}} helper can only test for properties, not arbitrary expressions. The best thing to do in cases like this is therefore to write a property computing whatever conditional you want to test for. personIsJohn: function() { return this.get(‘person’) === ‘John’; }.property(‘person’) Then do {{#if personIsJohn}}. Note: If you find this too limiting, you can … Read more

Ember.js: Reloading a .hasMany relationship given through “links” in payload

DS.Model.reopen({ reloadLink: function (linkKey) { if ($.isArray(linkKey)) { var promises = []; for (var i = 0; i < linkKey.length; i++) { promises.push(this.reloadLink(linkKey[i])); } return Em.RSVP.all(promises); } else { var rel = this._relationships[linkKey]; if (rel) { if (rel.reload) { return rel.reload(); } else if (rel.fetchLink) { return rel.fetchLink(); } } } } }); Example: model: … Read more

Ember CLI testing complicated model relationships

If you are using Ember default ‘Ember-QUnit’ then you have to list all the models in needs. But there is an alternative for testing which I am using i.e. ember-data-factory-guy. This is used to create factory instead of fixture data when testing Model, component, controller etc. You can go through it. https://github.com/danielspaniel/ember-data-factory-guy

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)