Create rails_admin_path_for_resource helper

This commit is contained in:
Karina Kwiatek 2021-08-06 13:38:24 +02:00
parent 4b52f900f2
commit 3570171b25
4 changed files with 7 additions and 3 deletions

View File

@ -169,4 +169,8 @@ module ApplicationHelper
def list_title(list)
generate_title list.name
end
def rails_admin_path_for_resource(resource)
[rails_admin_path, resource.model_name.param_key, resource.id].join('/')
end
end

View File

@ -39,6 +39,6 @@
%i.fa.fa-exclamation-triangle
= t 'views.actions.report'
- if current_user.has_role? :administrator
%a.dropdown-item{ href: "#{rails_admin_path}/answer/#{a.id}", target: '_blank' }
%a.dropdown-item{ href: rails_admin_path_for_resource(a), target: '_blank' }
%i.fa.fa-gears
View in Kontrollzentrum

View File

@ -19,7 +19,7 @@
%i.fa.fa-exclamation-triangle
= t 'views.actions.report'
- if current_user.has_role? :administrator
%a.dropdown-item{ href: "#{rails_admin_path}/question/#{a.question.id}", target: '_blank' }
%a.dropdown-item{ href: rails_admin_path_for_resource(a.question), target: '_blank' }
%i.fa.fa-gears
View in Kontrollzentrum
%h6.text-muted.media-heading.answerbox__question-user

View File

@ -29,6 +29,6 @@
%i.fa.fa-ban
= t 'views.actions.ban'
- if current_user.has_role? :administrator
%a.dropdown-item{ href: "#{rails_admin_path}/user/#{user.id}", target: '_blank' }
%a.dropdown-item{ href: rails_admin_path_for_resource(user), target: '_blank' }
%i.fa.fa-cogs
"View in Kontrollzentrum"