devnacho / mountain_view

Living styleguide for Rails
MIT License
273 stars 29 forks source link

Adjusting MountainView::Engine routes #45

Closed MikeRogers0 closed 7 years ago

MikeRogers0 commented 7 years ago

Is there a way to change the mountain_view mounted engine styleguide path from (When I run rake routes):

Routes for MountainView::Engine:
            root GET  /                         mountain_view/styleguide#index
styleguide_index GET  /styleguide(.:format)     mountain_view/styleguide#index
      styleguide GET  /styleguide/:id(.:format) mountain_view/styleguide#show

to

Routes for MountainView::Engine:
            root GET  /                         mountain_view/styleguide#index
styleguide_index GET  /(.:format)     mountain_view/styleguide#index
      styleguide GET  /:id(.:format) mountain_view/styleguide#show

I've mounted my engine on a subdomain like:

  constraints subdomain: "style" do
    mount MountainView::Engine => "/"
  end
tombeynon commented 7 years ago

Hey @MikeRogers0 - fancy seeing you here 😉

Setting the styleguide resource to use / for it's path isn't possible with the current setup - see config/routes.

It would be pretty easy to add a config for styleguide_path (defaulting to 'styleguide'), and just adjust the route resource to resources :styleguide, only: [:index, :show], path: MountainView.configuration.styleguide_path.

Not sure if @kitop or @devnacho would be happy with this, but it seems like a pretty useful config option to me.

kitop commented 7 years ago

@MikeRogers0 Thanks for reaching out. As @tombeynon said, that is not possible right now, but it would actually be a very useful config option.

More than happy to accept PR's if you want to work on it, otherwise I can give it a look sometime this weekend.

devnacho commented 7 years ago

@MikeRogers0 @tombeynon I agree with @kitop that this would be very useful 😃

MikeRogers0 commented 7 years ago

46 PR sent, it still has some work to do on it but I'd love to know your thoughts.