tricknotes / ember-cli-rails

Unify your EmberCLI and Rails Workflows
http://thoughtbot.github.io/ember-cli-rails/
MIT License
713 stars 205 forks source link

Add note about changing rootURL when using a custom path #504

Closed ndbroadbent closed 7 years ago

ndbroadbent commented 7 years ago

I'm new to ember-cli-rails, and this is the first issue I ran into (see #503)

dirtyhenry commented 7 years ago

I ran into this issue. The rootURL in Ember's config file needs a trailing / character or you'll get a warning from Ember. In the example from the README file, the trailing / is missing. Maybe it's worth updating as well.

ndbroadbent commented 7 years ago

Oh yeah I ran into the trailing slash issue too. I was pretty confused about that. I just don't understand why it's necessary. It seems like a very easy fix, but the Ember developers decided that a trailing slash is very important? What's the reasoning?

It's also pretty annoying, because you can't force a trailing slash in Rails routes. Rails strips all trailing slashes before it hits your routes, so there's no way to check if it is present.

seanpdoyle commented 7 years ago

Thanks for opening this PR, @ndbroadbent!

Would you mind addressing https://github.com/thoughtbot/ember-cli-rails/pull/504#issuecomment-263247745 in this PR as well?

nruth commented 7 years ago

We use rack-rewrite to handle the trailing / issue.

It's bemusing to strip / off for rails pages but keep them for ember pages, but seems to work:

    #remove trailing slashes
    r301 %r{\A/(?!emberapp1)(?!emberapp2)(.*)/\Z}, '/$1'

    # otherwise ember crashes with root-url not containing /
    r302 '/emberapp1', '/emberapp1/'
    r302 '/emberapp2', '/emberapp2/'