Router doesn't load index

When you have a resource with no routes below resource.index doesn’t load. I have to add at least one route. Any ideas how to fix this?

Currently my router looks like this

@resource 'hashtag', path: 'hashtag/:hashtag_id', ->
  @route 'null' # => Fake route to allow index to work

You can actually just supply an empty anonymous function to create the implicit resource.index route.

NOTE: If you define a resource using this.resource and do not supply a function, then the implicit resource.index route is not created. In that case, /resource will only use the ResourceRoute, ResourceController, and resource template.

Defining Your Routes - Routing - Ember Guides

Can you explain more?

@resource 'hashtag', path: 'hashtag/:hashtag_id', ->

will create a hashtag.index route but:

@resource 'hashtag', path: 'hashtag/:hashtag_id'

will only create the hashtag route

1 Like

Thats perfect, thanks :slight_smile:

This topic was automatically closed after 3 days. New replies are no longer allowed.