0

还没有找到任何可行的解决方案来解决这个问题。我正在使用 monologue gem 将基本的博客功能添加到我的应用程序中,但是我真的很想重命名 gem 提供的默认 '/monologue' 路由。

gem中封装的引擎路由如下:

Monologue::Engine.routes.draw do
  root to:  "posts#index"
  get "/page/:page", to:  "posts#index", as:  "posts_page"
  get "/feed" => "posts#feed", as:  "feed", defaults: {format: :rss}

  get "/tags/:tag" =>"tags#show", as: "tags_page"

  namespace :admin, path: "monologue" do
    get "/" => "posts#index", as:  "" # responds to admin_url and admin_path
    get "/page/:page", to:  "posts#index", as:  "posts_page"
    get "logout" => "sessions#destroy"
    get "login" => "sessions#new"
    resources :sessions
    resources :posts
    resources :users
    get "comments" => "comments#show", as: "comments"

    match "/post/preview"=>"posts#preview", :as=>"post_preview", :via => [:put, :post]
  end

  get "*post_url" => "posts#show", as:  "post"
end

在我的应用程序的 routes.rb 中,我试图重新路由它,并在前面加上类似这样的东西,但它似乎没有在 rails 注册。

Monologue::Engine.routes.prepend do
  namespace :admin, path: "create" do
    .......
  end
end
4

1 回答 1

0

在您的应用程序中,您可以在根级别挂载,或者简单地将任何您想要的作为父路由:

mount Monologue::Engine, :at => ""

或者,

mount Monologue::Engine, :at => "/blog"

要更改父域之外的路由(上图),您需要更改 Monologue 中的路由。

于 2016-04-13T23:17:04.717 回答