Ruby on rails jsonapi资源跨版本关系

Ruby on rails jsonapi资源跨版本关系,ruby-on-rails,ruby,jsonapi-resources,Ruby On Rails,Ruby,Jsonapi Resources,如何在不复制资源的相关资源和控制器的情况下添加资源的新版本 假设我有一个由以下路由描述的API: namespace :api do namespace :v1 do jsonapi_resources :contacts jsonapi_resources :phone_numbers end end class Api::V1::ContactResource < JSONAPI::Resource attributes :first_name, :las

如何在不复制资源的相关资源和控制器的情况下添加资源的新版本

假设我有一个由以下路由描述的API:

namespace :api do
  namespace :v1 do
    jsonapi_resources :contacts
    jsonapi_resources :phone_numbers
  end
end

class Api::V1::ContactResource < JSONAPI::Resource
  attributes :first_name, :last_name
  has_one :phone_number
end
我正在做一个有很多相关资源的项目,我不想重复所有这些资源,有什么建议吗

class Api::V2::ContactResource < JSONAPI::Resource
  attributes :full_name
  has_one :phone_number, related_class: Api::V1::PhoneNumberResource
end