📜  具有友好 ID 的活动管理员 - Ruby 代码示例

📅  最后修改于: 2022-03-11 15:04:46.654000             🧑  作者: Mango

代码示例1
# app/admin/group.rb

  # find record with slug(friendly_id)
  controller do
    def find_resource
      begin
        scoped_collection.where(slug: params[:id]).first!
      rescue ActiveRecord::RecordNotFound
        scoped_collection.find(params[:id])
      end
    end
  end