Skip to content

Commit

Permalink
Use keywords in routes mapping
Browse files Browse the repository at this point in the history
Rails deprecates hash key path mapping

See: rails/rails#52422
  • Loading branch information
tvdeyen committed Aug 4, 2024
1 parent d506835 commit 1711795
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
44 changes: 22 additions & 22 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
Alchemy::Engine.routes.draw do
root to: "pages#index"

get "/sitemap.xml" => "pages#sitemap", :format => "xml"
get "/sitemap.xml", to: "pages#sitemap", format: "xml"

scope Alchemy.admin_path, {constraints: Alchemy.admin_constraints} do
get "/" => redirect("#{Alchemy.admin_path}/dashboard"), :as => :admin
get "/dashboard" => "admin/dashboard#index", :as => :admin_dashboard
get "/dashboard/info" => "admin/dashboard#info", :as => :dashboard_info
get "/help" => "admin/dashboard#help", :as => :help
get "/dashboard/update_check" => "admin/dashboard#update_check", :as => :update_check
get "/leave" => "admin/base#leave", :as => :leave_admin
get "/", to: redirect("#{Alchemy.admin_path}/dashboard"), as: :admin
get "/dashboard", to: "admin/dashboard#index", as: :admin_dashboard
get "/dashboard/info", to: "admin/dashboard#info", as: :dashboard_info
get "/help", to: "admin/dashboard#help", as: :help
get "/dashboard/update_check", to: "admin/dashboard#update_check", as: :update_check
get "/leave", to: "admin/base#leave", as: :leave_admin
end

namespace :admin, {path: Alchemy.admin_path, constraints: Alchemy.admin_constraints} do
Expand Down Expand Up @@ -105,13 +105,13 @@

resources :sites

get "/styleguide" => "styleguide#index"
get "/styleguide", to: "styleguide#index"
end

get "/attachment/:id/download(/:name)" => "attachments#download",
:as => :download_attachment
get "/attachment/:id/show(/:name)" => "attachments#show",
:as => :show_attachment
get "/attachment/:id/download(/:name)", to: "attachments#download",
as: :download_attachment
get "/attachment/:id/show(/:name)", to: "attachments#show",
as: :show_attachment

resources :messages, only: [:index, :new, :create]
resources :elements, only: :show
Expand All @@ -123,8 +123,8 @@
resources :elements, only: [:index, :show]

resources :pages, only: [:index] do
get "elements" => "elements#index", :as => "elements"
get "elements/:named" => "elements#index", :as => "named_elements"
get "elements", to: "elements#index", as: "elements"
get "elements/:named", to: "elements#index", as: "named_elements"
collection do
get :nested
end
Expand All @@ -133,8 +133,8 @@
end
end

get "/pages/*urlname(.:format)" => "pages#show", :as => "page"
get "/admin/pages/:id(.:format)" => "pages#show", :as => "preview_page"
get "/pages/*urlname(.:format)", to: "pages#show", as: "page"
get "/admin/pages/:id(.:format)", to: "pages#show", as: "preview_page"

resources :nodes, only: [:index] do
member do
Expand All @@ -144,14 +144,14 @@
end
end

get "/:locale" => "pages#index",
:constraints => {locale: Alchemy::RoutingConstraints::LOCALE_REGEXP},
:as => :show_language_root
get "/:locale", to: "pages#index",
constraints: {locale: Alchemy::RoutingConstraints::LOCALE_REGEXP},
as: :show_language_root

# The page show action has to be last route
constraints(locale: Alchemy::RoutingConstraints::LOCALE_REGEXP) do
get "(/:locale)/*urlname(.:format)" => "pages#show",
:constraints => Alchemy::RoutingConstraints.new,
:as => :show_page
get "(/:locale)/*urlname(.:format)", to: "pages#show",
constraints: Alchemy::RoutingConstraints.new,
as: :show_page
end
end
2 changes: 1 addition & 1 deletion lib/alchemy/install/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def inject_routes(auto_accept = false)
mountpoint = ask("- At which path do you want to mount Alchemy CMS at?", default: mountpoint)
end

inject_into_file "./config/routes.rb", "\n mount Alchemy::Engine => '#{mountpoint}'\n",
inject_into_file "./config/routes.rb", "\n mount Alchemy::Engine, at: '#{mountpoint}'\n",
{after: SENTINEL, verbose: true}
end

Expand Down
4 changes: 2 additions & 2 deletions spec/libraries/alchemy/install/tasks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
subject
expect(tasks).to have_received(:inject_into_file).with(
"./config/routes.rb",
"\n mount Alchemy::Engine => '/'\n",
"\n mount Alchemy::Engine, at: '/'\n",
{
after: Alchemy::Install::Tasks::SENTINEL,
verbose: true
Expand Down Expand Up @@ -64,7 +64,7 @@
subject
expect(tasks).to have_received(:inject_into_file).with(
"./config/routes.rb",
"\n mount Alchemy::Engine => '/cms'\n",
"\n mount Alchemy::Engine, at: '/cms'\n",
{
after: Alchemy::Install::Tasks::SENTINEL,
verbose: true
Expand Down

0 comments on commit 1711795

Please sign in to comment.