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.
This commit is contained in:
@@ -46,4 +46,35 @@ Rails.application.routes.draw do
|
|||||||
|
|
||||||
# Static pages
|
# Static pages
|
||||||
resources :pages, path: "/", only: [:show]
|
resources :pages, path: "/", only: [:show]
|
||||||
|
|
||||||
|
resolve "Budget::Investment" do |investment, options|
|
||||||
|
[investment.budget, :investment, options.merge(id: investment)]
|
||||||
|
end
|
||||||
|
|
||||||
|
resolve("Topic") { |topic, options| [topic.community, topic, options] }
|
||||||
|
|
||||||
|
resolve "Legislation::Proposal" do |proposal, options|
|
||||||
|
[proposal.process, :proposal, options.merge(id: proposal)]
|
||||||
|
end
|
||||||
|
|
||||||
|
resolve "Vote" do |vote, options|
|
||||||
|
[*resource_hierarchy_for(vote.votable), vote, options]
|
||||||
|
end
|
||||||
|
|
||||||
|
resolve "Legislation::Question" do |question, options|
|
||||||
|
[question.process, :question, options.merge(id: question)]
|
||||||
|
end
|
||||||
|
|
||||||
|
resolve "Legislation::Annotation" do |annotation, options|
|
||||||
|
[annotation.draft_version.process, :draft_version, :annotation,
|
||||||
|
options.merge(draft_version_id: annotation.draft_version, id: annotation)]
|
||||||
|
end
|
||||||
|
|
||||||
|
resolve "Poll::Question" do |question, options|
|
||||||
|
[:question, options.merge(id: question)]
|
||||||
|
end
|
||||||
|
|
||||||
|
resolve "SDG::LocalTarget" do |target, options|
|
||||||
|
[:local_target, options.merge(id: target)]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,7 +19,3 @@ resources :budgets, only: [:show, :index] do
|
|||||||
resource :stats, only: :show, controller: "budgets/stats"
|
resource :stats, only: :show, controller: "budgets/stats"
|
||||||
resource :executions, only: :show, controller: "budgets/executions"
|
resource :executions, only: :show, controller: "budgets/executions"
|
||||||
end
|
end
|
||||||
|
|
||||||
resolve "Budget::Investment" do |investment, options|
|
|
||||||
[investment.budget, :investment, options.merge(id: investment)]
|
|
||||||
end
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
resources :communities, only: [:show] do
|
resources :communities, only: [:show] do
|
||||||
resources :topics
|
resources :topics
|
||||||
end
|
end
|
||||||
|
|
||||||
resolve("Topic") { |topic, options| [topic.community, topic, options] }
|
|
||||||
|
|||||||
@@ -39,20 +39,3 @@ namespace :legislation do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resolve "Legislation::Proposal" do |proposal, options|
|
|
||||||
[proposal.process, :proposal, options.merge(id: proposal)]
|
|
||||||
end
|
|
||||||
|
|
||||||
resolve "Vote" do |vote, options|
|
|
||||||
[*resource_hierarchy_for(vote.votable), vote, options]
|
|
||||||
end
|
|
||||||
|
|
||||||
resolve "Legislation::Question" do |question, options|
|
|
||||||
[question.process, :question, options.merge(id: question)]
|
|
||||||
end
|
|
||||||
|
|
||||||
resolve "Legislation::Annotation" do |annotation, options|
|
|
||||||
[annotation.draft_version.process, :draft_version, :annotation,
|
|
||||||
options.merge(draft_version_id: annotation.draft_version, id: annotation)]
|
|
||||||
end
|
|
||||||
|
|||||||
@@ -8,7 +8,3 @@ resources :polls, only: [:show, :index] do
|
|||||||
resources :answers, controller: "polls/answers", only: [:create, :destroy], shallow: false
|
resources :answers, controller: "polls/answers", only: [:create, :destroy], shallow: false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resolve "Poll::Question" do |question, options|
|
|
||||||
[:question, options.merge(id: question)]
|
|
||||||
end
|
|
||||||
|
|||||||
@@ -24,7 +24,3 @@ namespace :sdg_management do
|
|||||||
get "#{type}/:id/edit", to: "relations#edit", as: "edit_#{type.singularize}"
|
get "#{type}/:id/edit", to: "relations#edit", as: "edit_#{type.singularize}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resolve "SDG::LocalTarget" do |target, options|
|
|
||||||
[:local_target, options.merge(id: target)]
|
|
||||||
end
|
|
||||||
|
|||||||
Reference in New Issue
Block a user