pushtype / push_type

PushType is a modern, open source content management system for Ruby on Rails.
http://www.pushtype.org
Other
290 stars 32 forks source link

PushType install fails if app uses root route #19

Closed brandondrew closed 7 years ago

brandondrew commented 7 years ago

In order to install PushType, it is necessary to relinquish the root route of your app, so that PushType can take it over.

Rails.application.routes.draw do

  mount_push_type

#  root "welcome#index"

Since much of what appears on PushType's newly created home page is in the installation instructions, I think it would make more sense to

  1. have PushType use some other route, such as /push_type/setup, instead of the app root, and
  2. put a link to that in the installation instructions.
aaronrussell commented 7 years ago

As of the current version, that is right. the FrontEndController is added to your app and the front end routes are in your app. You can actually override PushType's root by putting your own root path above in routes.rb.

Rails.application.routes.draw do
  root "welcome#index"   # <= order of precedence means this is matched first
  mount_push_type
end

In the next version - 0.10.0 - this behaviour has been changed. The FrontEndController is now in an isolated engine, so it can be mounted according to your needs:

Rails.application.routes.draw do
  mount_push_type admin: 'cms', front_end: 'blog'
end
aaronrussell commented 7 years ago

Just re-reading your question, I may have missed part of what you're asking...

The setup page that is shown is only shown when you haven't created a homepage.

In config/initializers/push_type.rb, you'll see the following option:

config.home_slug = 'home'

This is essentially telling PushType that your homepage - ie your root path - should redirect to the node with the slug "home". If you haven't created that node yet, you'll see the setup screen.

brandondrew commented 7 years ago

I tried putting my root route above mount_push_type, but I get more or less the same error as I get with it after:

 [25067] ! Unable to load application: ArgumentError: Invalid route name, already in use: 'root'
 You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here:
 http://guides.rubyonrails.org/routing.html#restricting-the-routes-created
 bundler: failed to load command: puma (/Users/brandon/.rbenv/versions/2.3.1/bin/puma)
hanchang commented 7 years ago

I have the same issue - tried adding root route above mount_push_type but same error message.

Looks like version 0.10.0 will solve the issue though? Do you guys have an ETA on when that will be out? How can I help? Thanks for all the work you're doing on this, Rails desperately needs a solid open source CMS solution so I'm excited to see this coming together!

aaronrussell commented 7 years ago

Yes, 0.10.0 hopefully solves this. There is a beta available now. Try:

gem 'push_type', '>= 0.10.0.beta.2'

The main difference is that the FrontEndController is mounted as an engine - by default at the root path. However, as it has it's own namespace, you can safely have multiple routes with the root name.

main_app.root_path # => '/'
push_type.root_path # => '/'

So if your app has it's own root_path - as mentioned above - make sure it is listed first in your routes.rb so that it maps to your controller rather than to PushType::FrontEndController.

If you're using 0.9.x on a production site, i would not recommend using the 0.10.0.beta quite yet. However, if you're toying around with PushType and just kicking the tyres, by all means give it a go.

aaronrussell commented 7 years ago

Just an update for you guys following this. I had to revert mounting the FrontEndController as an isolated engine as it caused various issues with sharing helpers between PushType and the host app.

However, the problem with root_path is fixed. See the latest notes here.

The latest beta (4) seems stable so you should be good to give it a try.