avohq/docs

Compatibility with Friendly IDs

vitaly107 opened this issue · 1 comments

We are using Friendly IDs gem to make friendly URLs for one of our model - Page. So we have:

class Page < ApplicationRecord
  extend FriendlyId
  friendly_id :name, use: :slugged
end

However if we try to manage Page resource using Avo it fails to find page id.

We tried to create a class and add extend as follows:

class Avo::ApplicationController < ActionController::Base
  extend FriendlyId
  friendly_id :name, use: :slugged
end

But this throwas an error.

Eventually I found a temporary solution to hack one of the avo classes as follows:

def set_model
@model = if @resource.model_class.name == 'Page'
eager_load_files(@resource, @resource.model_class).friendly.find params[:id]
else
eager_load_files(@resource, @resource.model_class).find params[:id]
end
end

Please can we have a proper solution so we can use both your gem and Friendly IDs gem in a number of our commercial applications? Many thanks in advance.

wrong place