0

Haven't been able to find any workable solutions to this issue. I'm using the monologue gem to add basic blog functionality to my app, however I'd really like to rename the default '/monologue' route as provided by the gem.

The engine's routes packaged in the gem are as follows:

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

In my app's routes.rb, I'm trying to reroute it with a prepend with something like this but it doesn't seem to register with rails.

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

1 Answers1

0

In your app, you can mount at the root level, or simply put whatever you want as the parent route:

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

or,

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

To change the routes beyond the parent domain (above), you'll need to change the routes in Monologue..

Carson Cole
  • 4,183
  • 6
  • 25
  • 35
  • yeah, i was looking for a way to override the routes within monologue from my parent app. didn't want to have to modify the gem itself if that's possible – Christopher Changchien Apr 13 '16 at 23:18
  • Not sure how you can do that, nor would I recommend it, since it won't be easy pulling any new Monologue updates. The alternate choice is to add your own blogging functionality... – Carson Cole Apr 13 '16 at 23:20
  • yeah, sadly i was coming to the same conclusions. just trying to save some time. thanks for the response though! – Christopher Changchien Apr 13 '16 at 23:25
  • Blog functionality is pretty basic and you may find that you have better control--that's my own usual preference, but it will definitely take longer. The other option is to write your own blog functionality and put it in an engine, then you can swap it out if you ultimately decide you want something else. – Carson Cole Apr 13 '16 at 23:31