# Discourse erroneously requesting plural of route?

**URL:** https://meta.discourse.org/t/discourse-erroneously-requesting-plural-of-route/97962
**Category:** Development
**Created:** [24.Сентябрь.2018 19:42:06 UTC](https://meta.discourse.org/t/discourse-erroneously-requesting-plural-of-route/97962 "2018-09-24T19:42:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Kampfkarren](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kampfkarren/32/109627_2.png) [@Kampfkarren](https://meta.discourse.org/u/Kampfkarren)
#### Post date: [24.Сентябрь.2018 19:42:06 UTC](https://meta.discourse.org/t/discourse-erroneously-requesting-plural-of-route/97962/1 "2018-09-24T19:42:06Z")

</div>

In my plugin routes, I had the following (not these exact names, but hopefully the point is clear)

```plaintext
		get "/u/:username/thing" => "user_thing#index", constraints: { username: RouteFormat.username }
		get "/u/:username/thing/setup" => "user_thing#setup_index", constraints: { username: RouteFormat.username }
		post "/u/:username/thing/setup" => "user_thing#setup", constraints: { username: RouteFormat.username }

```

My route map was:

```plaintext
export default function() {
	this.route(
		'user',
		{ path: '/u/:username', resetNamespace: true},
		function() {
			this.route('thing', function() {
				this.route('setup')
			})
		}
	)
}

```

This has worked so far. Recently, I wanted to add the new routes (note: they’re aligned to root):

```plaintext
		resource :thing_foobar, path: "thing/foobar/:foobar_id"

```

(Writing these fake names is becoming difficult 😕)

Now my route map is:

```plaintext
export default function() {
   this.route(
   	'user',
   	{ path: '/u/:username', resetNamespace: true},
   	function() {
   		this.route('thing', function() {
   			this.route('setup')
   		})
   	}
   )

   this.route(
   	'thing',
   	function() {
   		this.route('redirect', { path: '/foobar/:foobar_id' })
   	}
   )
}

```

Going to mysite.tld/thing/foobar/1, I get redirected to /404

I check my network and I have the following 404:

[http://mysite.tld/foobars/1?\_=1537817415772](http://mysite.tld/foobars/1?_=1537817415772)

What? Why is it requesting a plural form of my route instead of the actual route? Is it because it’s a relative path or something? I don’t understand.

---

<div class="post-metadata">

### Author: ![Kampfkarren](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kampfkarren/32/109627_2.png) [@Kampfkarren](https://meta.discourse.org/u/Kampfkarren)
#### Post date: [24.Сентябрь.2018 21:36:16 UTC](https://meta.discourse.org/t/discourse-erroneously-requesting-plural-of-route/97962/2 "2018-09-24T21:36:16Z")

</div>

I’m not sure if this is exactly what caused it, but I was missing a `model() {` declaration in my route that was giving the plural. I don’t know why these are correlated, if they are.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [24.Сентябрь.2018 21:51:42 UTC](https://meta.discourse.org/t/discourse-erroneously-requesting-plural-of-route/97962/3 "2018-09-24T21:51:42Z")

</div>

Glad to hear you got it working. I was interested to see what was causing this, so did a little digging:

> [@Kampfkarren](#):
>
> I don’t know why these are correlated, if they are.

If you don’t define `model()` explicitly, the built-in Ember implementation is used:

> <https://github.com/emberjs/ember.js/blob/v2.18.2/packages/ember-routing/lib/system/route.js#L1538-L1565>

This ‘guesses’ the name of the model for the route, and then looks it up using the application’s ‘store’:

> <https://github.com/emberjs/ember.js/blob/v2.18.2/packages/ember-routing/lib/system/route.js#L1587-L1589>

The store’s default behaviour is to construct the URL automatically. It “pluralizes” the name of the model, which explains why you saw a request for /foobar **s**

[https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/adapters/rest.js.es6#L64-L69](https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/adapters/rest.js.es6#L64-L69)

---

<div class="post-metadata">

### Author: ![Kampfkarren](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kampfkarren/32/109627_2.png) [@Kampfkarren](https://meta.discourse.org/u/Kampfkarren)
#### Post date: [25.Сентябрь.2018 03:25:08 UTC](https://meta.discourse.org/t/discourse-erroneously-requesting-plural-of-route/97962/4 "2018-09-25T03:25:08Z")

</div>

So is there anyway to specify a route _without_ a model? Am I missing the point of routes?
