Ruben Martinez Jr.
Ruben Martinez Jr.

Reputation: 3120

"Route was not found" Ember.js

I'm very new to Ember.js, so forgive if this is bad question:

I have a route defined as follows:

App.Router.map(function() {
    this.resource('find', { path: 'find/:lat/:lon' });
});

Given this, I would expect a path such as http://localhost/#/find/1/2 to work, and indeed, it does. However, In my IndexRoute, I have an action that does essentially the following:

var lat = 0; //I actually have logic here that grabs lat/lon from
var lon = 0; //HTML5 geolocator, but this is a simplified version
this.transitionTo('find/'+lat+'/'+lon);

When I trigger this action, I get an error:

Uncaught Error: Assertion Failed: The route find/0/0 was not found 

I've looked at other similar questions and read through the docs but I can't find what's wrong. I'm sure it's a tiny mistake...Thanks for your help!

Upvotes: 1

Views: 1005

Answers (1)

Kingpin2k
Kingpin2k

Reputation: 47367

transitionTo builds up your url, you should pass ids, or model as arguments to transitionTo and let Ember build up your url.

this.transitionTo('find', 1, 2);

Here's an example with ids: http://emberjs.jsbin.com/royiyisi/1/edit

with a model: http://emberjs.jsbin.com/royiyisi/2/edit

Upvotes: 2

Related Questions