LandonSchropp
LandonSchropp

Reputation: 10244

Setting the Ember root URL without redirection

Let's say my Router looks like this:

Bananas.Router.map ->
  @resource "bananas", ->
    @route 'index', path: '/'

and my BananasIndexRoute looks like this:

Bananas.BananasIndexRoute = Ember.Route.extend
  setupController: (controller) -> 
    controller.set("content", [ "baby", "manzano", "burro", "plantain", "red" ])

Manipulating the bananas belongs in the BananaController, but when the user visits waytomanybananas.com, I'd like they to be able to interact with my application. Currently, I'm accomplishing this by redirecting the user to the bananas path like this:

Bananas.IndexRoute = Ember.Route.extend
  redirect: -> @transitionTo("bananas")

However, I'd prefer to have the the application render the bananas route when I visit the root URL (the equivilent of root in Rails). What's the best way to accomplish this using Ember?

Upvotes: 0

Views: 1919

Answers (2)

intuitivepixel
intuitivepixel

Reputation: 23322

this would do it

Bananas.Router.map ->
  @resource "bananas", path: '/'

Upvotes: 1

MilkyWayJoe
MilkyWayJoe

Reputation: 9092

Add a path to your resource:

Bananas.Router.map ->
    @resource 'bananas', { path: '/' }, ->

Upvotes: 1

Related Questions