I have a model named Company
that has code
. The column is used for friendly_id
.
class Company < ActiveRecord::Base
extend FriendlyId
friendly_id :code, use: :slugged
end
ActiveAdmin
doesn't recognize friendly_id
, so that I had to override find_resource
method like this:
ActiveAdmin.register Company do
controller do
def find_resource
scoped_collection.friendly.find(params[:id])
end
end
end
With this code I can edit the model attributes by ActiveAdmin, but breadcrumbs list in edit page shows wrong company's name. (That is using id
, instead of code
)
Where and how can I configure to use ActiveAdmin
and friendly_id
at the sametime?