Files
grecia/config/routes/sdg_management.rb
Javi Martín 60dbda600d Move resolve clauses to the main routes file
We're going to add some constraints in the routes file, and if we add a
`resolve` clause inside a constraints block, we get an error saying that
"The resolve method can't be used inside a routes scope block" when
starting the application.
2024-11-06 11:07:00 +01:00

27 lines
1.0 KiB
Ruby

namespace :sdg_management do
root to: "goals#index"
resources :goals, only: [:index]
resources :targets, only: [:index]
resources :local_targets, except: [:show]
resource :homepage, controller: :homepage, only: [:show] do
resource :header, controller: :header, only: [:new, :create, :edit, :update, :destroy]
end
resources :phases, only: [], as: :sdg_phases do
resources :cards, except: [:index, :show], as: :widget_cards
end
types = SDG::Related::RELATABLE_TYPES.map(&:tableize)
types_constraint = /#{types.join("|")}/
get "*relatable_type", to: "relations#index", as: "relations", relatable_type: types_constraint
get "*relatable_type/:id/edit", to: "relations#edit", as: "edit_relation", relatable_type: types_constraint
patch "*relatable_type/:id", to: "relations#update", as: "relation", relatable_type: types_constraint
types.each do |type|
get type, to: "relations#index", as: type
get "#{type}/:id/edit", to: "relations#edit", as: "edit_#{type.singularize}"
end
end