Skip to content

Commit

Permalink
Do not add leading slash to default admin path
Browse files Browse the repository at this point in the history
Since 871e77e we allow to set a custom
admin path (ie. `/backend` instead of `/admin`). The default is set to
`/admin` and since the admin dashboard redirect rule from `/admin` to
`/admin/dashboard` uses this value the redirect destination is a root
path.

This causes no problems, unless you mount Alchemy at some other path
(`/cms` instead of just `/`). Because the redirect rule has a leading
slash the Rails router does not take the mount path into account and
redirects to `/admin/dashboard` instead of `/cms/admin/dashboard`.

Closes AlchemyCMS#1244
  • Loading branch information
tvdeyen committed Nov 24, 2017
1 parent 0ed9f0f commit aa61750
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ For example, these settings:
```ruby
# config/initializers/alchemy.rb

Alchemy.admin_path = '/backend'
Alchemy.admin_path = 'backend'
Alchemy.admin_constraints = {subdomain: 'hidden'}
```

Expand Down
10 changes: 5 additions & 5 deletions lib/alchemy/paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Alchemy has some defaults for admin path and admin constraints:
#
# +Alchemy.admin_path defaults to +'/admin'+
# +Alchemy.admin_path defaults to +'admin'+
# +Alchemy.admin_constraints defaults to +{}+
#
# Anyway, you can tell Alchemy about your routing configuration:
Expand All @@ -17,18 +17,18 @@
#
# == Example
#
# If you do not wish to use the default admin interface routing ('example.com/admin/')
# and prefer e.g. 'hidden.example.com/backend/', those are the settings you need:
# If you do not wish to use the default admin interface routing ('example.com/admin')
# and prefer e.g. 'hidden.example.com/backend', those are the settings you need:
#
# # config/initializers/alchemy.rb
# Alchemy.admin_path = '/backend'
# Alchemy.admin_path = 'backend'
# Alchemy.admin_constraints = {subdomain: 'hidden'}
#
module Alchemy
mattr_accessor :admin_path, :admin_constraints

# Defaults
#
@@admin_path = '/admin'
@@admin_path = 'admin'
@@admin_constraints = {}
end

0 comments on commit aa61750

Please sign in to comment.