Update Raid blueprint with views
This commit is contained in:
parent
e10571b131
commit
2001bbcb34
2 changed files with 18 additions and 7 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
module Api
|
module Api
|
||||||
module V1
|
module V1
|
||||||
class RaidBlueprint < ApiBlueprint
|
class RaidBlueprint < ApiBlueprint
|
||||||
|
view :nested do
|
||||||
field :name do |raid|
|
field :name do |raid|
|
||||||
{
|
{
|
||||||
en: raid.name_en,
|
en: raid.name_en,
|
||||||
|
|
@ -10,7 +11,13 @@ module Api
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
fields :slug, :level, :group, :element
|
fields :slug, :level, :element
|
||||||
|
end
|
||||||
|
|
||||||
|
view :full do
|
||||||
|
include_view :nested
|
||||||
|
association :group, blueprint: RaidGroupBlueprint
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,11 @@ module Api
|
||||||
module V1
|
module V1
|
||||||
class RaidsController < Api::V1::ApiController
|
class RaidsController < Api::V1::ApiController
|
||||||
def all
|
def all
|
||||||
render json: RaidBlueprint.render(Raid.all)
|
render json: RaidBlueprint.render(Raid.all, view: :full)
|
||||||
|
end
|
||||||
|
|
||||||
|
def groups
|
||||||
|
render json: RaidGroupBlueprint.render(RaidGroup.all)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue