diff --git a/app/controllers/admin/milestones_controller.rb b/app/controllers/admin/milestones_controller.rb index 1ee5ecc10..c3019443a 100644 --- a/app/controllers/admin/milestones_controller.rb +++ b/app/controllers/admin/milestones_controller.rb @@ -67,6 +67,6 @@ class Admin::MilestonesController < Admin::BaseController end def milestoneable_path - polymorphic_path([:admin, *resource_hierarchy_for(@milestone.milestoneable)]) + admin_polymorphic_path(@milestone.milestoneable) end end diff --git a/app/controllers/admin/progress_bars_controller.rb b/app/controllers/admin/progress_bars_controller.rb index 1d05c0027..bbdbf4a41 100644 --- a/app/controllers/admin/progress_bars_controller.rb +++ b/app/controllers/admin/progress_bars_controller.rb @@ -64,6 +64,6 @@ class Admin::ProgressBarsController < Admin::BaseController end def progress_bars_index - polymorphic_path([:admin, *resource_hierarchy_for(@progressable), ProgressBar.new]) + admin_polymorphic_path(@progressable.progress_bars.new) end end diff --git a/app/views/admin/audits/_audits.html.erb b/app/views/admin/audits/_audits.html.erb index 2018153b3..ee1f3c030 100644 --- a/app/views/admin/audits/_audits.html.erb +++ b/app/views/admin/audits/_audits.html.erb @@ -35,7 +35,7 @@ <%= link_to t("shared.show"), - polymorphic_path([:admin, *resource_hierarchy_for(audit)]), + admin_polymorphic_path(audit), class: "button hollow primary" %> diff --git a/app/views/admin/audits/show.html.erb b/app/views/admin/audits/show.html.erb index 75f873936..ee89b62d1 100644 --- a/app/views/admin/audits/show.html.erb +++ b/app/views/admin/audits/show.html.erb @@ -1,7 +1,7 @@ <% provide(:title) do %> <%= t("admin.audits.title") %> <% end %> -<%= back_link_to polymorphic_path([:admin, *resource_hierarchy_for(@audit.associated || @audit.auditable)]) %> +<%= back_link_to admin_polymorphic_path(@audit.associated || @audit.auditable) %>

<%= t("admin.audits.title") %>

diff --git a/app/views/admin/milestones/_form.html.erb b/app/views/admin/milestones/_form.html.erb index b7cc30270..2a3bd75d0 100644 --- a/app/views/admin/milestones/_form.html.erb +++ b/app/views/admin/milestones/_form.html.erb @@ -1,6 +1,6 @@ <%= render "shared/globalize_locales", resource: @milestone %> -<%= translatable_form_for [:admin, *resource_hierarchy_for(@milestone)] do |f| %> +<%= translatable_form_for @milestone, url: admin_polymorphic_path(@milestone) do |f| %>
diff --git a/app/views/admin/milestones/_milestones.html.erb b/app/views/admin/milestones/_milestones.html.erb index bcbf61885..84f4a65ab 100644 --- a/app/views/admin/milestones/_milestones.html.erb +++ b/app/views/admin/milestones/_milestones.html.erb @@ -1,7 +1,7 @@

<%= t("admin.milestones.index.milestone") %>

<%= link_to t("admin.progress_bars.manage"), - polymorphic_path([:admin, *resource_hierarchy_for(milestoneable.progress_bars.new)]), + admin_polymorphic_path(milestoneable.progress_bars.new), class: "button hollow float-right" %> <% if milestoneable.milestone_tag_list.any? %> @@ -31,9 +31,7 @@ <%= milestone.id %> - <%= link_to milestone.title, - polymorphic_path([:admin, *resource_hierarchy_for(milestone)], - action: :edit) %> + <%= link_to milestone.title, admin_polymorphic_path(milestone, action: :edit) %> <%= milestone.description %> @@ -59,7 +57,7 @@ <%= link_to t("admin.milestones.index.delete"), - polymorphic_path([:admin, *resource_hierarchy_for(milestone)]), + admin_polymorphic_path(milestone), method: :delete, class: "button hollow alert expanded" %> @@ -73,7 +71,6 @@

<%= link_to t("admin.milestones.index.new_milestone"), - polymorphic_path([:admin, *resource_hierarchy_for(milestoneable.milestones.new)], - action: :new), + admin_polymorphic_path(milestoneable.milestones.new, action: :new), class: "button hollow" %>

diff --git a/app/views/admin/progress_bars/_form.html.erb b/app/views/admin/progress_bars/_form.html.erb index 3598aea12..0a479245f 100644 --- a/app/views/admin/progress_bars/_form.html.erb +++ b/app/views/admin/progress_bars/_form.html.erb @@ -1,6 +1,6 @@ <%= render "shared/globalize_locales", resource: @progress_bar %> -<%= translatable_form_for [:admin, *resource_hierarchy_for(@progress_bar)] do |f| %> +<%= translatable_form_for @progress_bar, url: admin_polymorphic_path(@progress_bar) do |f| %>
diff --git a/app/views/admin/progress_bars/_progress_bars.html.erb b/app/views/admin/progress_bars/_progress_bars.html.erb index 3715c2f35..1ac03e331 100644 --- a/app/views/admin/progress_bars/_progress_bars.html.erb +++ b/app/views/admin/progress_bars/_progress_bars.html.erb @@ -1,8 +1,8 @@

<%= t("admin.progress_bars.index.title") %>

<%= link_to t("admin.progress_bars.index.new_progress_bar"), - polymorphic_path( - [:admin, *resource_hierarchy_for(ProgressBar.new(progressable: progressable))], + admin_polymorphic_path( + ProgressBar.new(progressable: progressable), action: :new ), class: "button float-right" %> @@ -37,12 +37,11 @@ <%= link_to t("admin.actions.edit"), - polymorphic_path([:admin, *resource_hierarchy_for(progress_bar)], - action: :edit), + admin_polymorphic_path(progress_bar, action: :edit), class: "button hollow" %> <%= link_to t("admin.actions.delete"), - polymorphic_path([:admin, *resource_hierarchy_for(progress_bar)]), + admin_polymorphic_path(progress_bar), method: :delete, class: "button hollow alert" %> diff --git a/app/views/admin/progress_bars/index.html.erb b/app/views/admin/progress_bars/index.html.erb index bcac8d7a4..df01e034a 100644 --- a/app/views/admin/progress_bars/index.html.erb +++ b/app/views/admin/progress_bars/index.html.erb @@ -2,7 +2,7 @@ <%= "#{t("admin.header.title")} - #{t("admin.progress_bars.index.title")}" %> <% end %> -<%= back_link_to polymorphic_path([:admin, *resource_hierarchy_for(@progressable)]) %> +<%= back_link_to admin_polymorphic_path(@progressable) %>
diff --git a/config/initializers/routes_hierarchy.rb b/config/initializers/routes_hierarchy.rb index 6223d9e74..ae86c07a5 100644 --- a/config/initializers/routes_hierarchy.rb +++ b/config/initializers/routes_hierarchy.rb @@ -63,4 +63,8 @@ module ActionDispatch::Routing::UrlFor polymorphic_path(resources) end end + + def admin_polymorphic_path(resource, options = {}) + polymorphic_path([:admin, *resource_hierarchy_for(resource)], options) + end end diff --git a/spec/shared/system/admin_progressable.rb b/spec/shared/system/admin_progressable.rb index 81cd2cb62..7fe2e33b2 100644 --- a/spec/shared/system/admin_progressable.rb +++ b/spec/shared/system/admin_progressable.rb @@ -5,7 +5,7 @@ shared_examples "admin_progressable" do |factory_name, path_name| let(:progressable_path) { send(path_name, *resource_hierarchy_for(progressable)) } let(:path) do - polymorphic_path([:admin, *resource_hierarchy_for(progressable.progress_bars.new)]) + admin_polymorphic_path(progressable.progress_bars.new) end context "Index" do