Skip to content

Using URLs with public IDs #2742

Closed Answered by krystof-k
krystof-k asked this question in Help
Discussion options

You must be logged in to vote

OK, I might have found a workaround.

I just added a new route:

Rails.application.routes.draw do
  authenticate :user, ->(user) { user.super_admin? } do
    mount Avo::Engine, at: Avo.configuration.root_path

    scope Avo.configuration.root_path, module: "avo" do
      get "l/:resources/:id", to: "redirect#redirect", as: "dashboard_permalink"
    end
  end

and a controller:

# app/controllers/avo/redirect_controller.rb

class Avo::RedirectController < ApplicationController
  def redirect
    avo_resource_name = params[:resources].singularize
    avo_resource_class_name = "Avo::Resources::#{avo_resource_name.classify}"
    avo_resource_class = avo_resource_class_name.safe_constantize

    r…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@adrianthedev
Comment options

Answer selected by krystof-k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants