I have a model Organisation
. This model has_many organisation_branches
.
The organisation_branch
has the address details in which the city_id
is present, which refers to the city table.
organisation.rb:
class Organisation < ApplicationRecord
has_many :organisation_branches
end
organisation_branch.rb
class OrganisationBranch < ApplicationRecord
belongs_to :organisation
belongs_to :city
end
organisation_serializer:
class OrganisationSerializer
include FastJsonapi::ObjectSerializer
attributes :id,:org_id,:organisation_name
has_many :organisation_branches
end
I need to display the Branch details with the name of the city retrieved from the city table. All this needs to be shown when an organisation is viewed.