Skip to content Skip to sidebar Skip to footer

Ember Render 404 With Invalid Url Slugs

I'm using dynamic URLs in my application for easy readability. The url structure is /[:organization_slug]/[:product_slug]. In other words, an organization is the owner of a product

Solution 1:

I believe your issue is that when you are trying to transition into a "catch all", Ember.js has no idea what that is. This is easy to fix as transitionTo() takes a 2nd parameter for specifying the model, which in your case would be the URL.

So, for a non-existent product, your route would look something like this:

App.BadRoute = Ember.Route.extend({
  model: function(){
    return"abcdproduct";
  },
  afterModel: function(badProduct){
    this.transitionTo('notFound', badProduct);
  }
});

See a basic working example here

Post a Comment for "Ember Render 404 With Invalid Url Slugs"