Router doesn't load index


#1

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

#2

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.

http://emberjs.com/guides/routing/defining-your-routes/#toc_resources


#3

Can you explain more?


#4
@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


#5

Thats perfect, thanks :slight_smile:


#6

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