Ember-cli-rails路由接近一个经典的rails应用



我有一个经典的rails应用程序与haml和api部分(exemple.com/api/v1/)。我正在用ember-cli-rails开发一个ember应用程序,我想在/front上访问它。

问题是当我重新加载它失败。应用程序返回haml页面或无法正确地为我路由。

我检查了这个问题,并试图实现它没有成功。

我的路线。我们有近400行。但目前唯一有效的是在文件的顶部添加

  namespace :front do
    get '/', to: 'front#index'
  end

当我去exemple.com/front是ok的。如果我点击user list,当我点击特定用户exemple.com/stores/5282/users/345时,我跳转到exemple.com/stores/5282/users的页面。当我重新加载

No route matches [GET] "/stores/5282/users"

为了避免失败,我添加了这个:

  match 'stores/*path', to: redirect('/front'), via: :all

但是它会回到我的ember应用程序的索引页,我也试过

  get 'stores/:all', to: "front#index"

但是仍然没有路由匹配。

EDIT: I've found a answer

  get 'stores/*other', to: "front/front#index"

答案是:

 namespace :front do
    get '/', to: 'front#index'
 end
 get 'stores/*other', to: 'front/front#index'

现在,当我去exemple.com/stores/5282/users,我刷新它在正确的余烬页。没有路由错误,没有重定向到/front

相关内容

最新更新