-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Hi,
Me again 😄
I'm using Roar as my representer. I have 3 models: Organization, Location, and Services.
Here's my LocationRepresenter, which also includes some properties from the Organization and Service models:
require 'roar/representer/json'
require 'roar/representer/feature/hypermedia'
module LocationRepresenter
include Roar::Representer::JSON
include Roar::Representer::Feature::Hypermedia
property :id
# more location properties
property :organization, extend: OrganizationRepresenter, class: Organization
collection :services, :extend => ServiceRepresenter, :class => Service
endHere's my Grape API location resource without Garner, which works fine:
...
get do
locations = Location.includes([:organization, :services]).page(params[:page]).per(params[:per_page])
locations.extend LocationsRepresenter
endIf I add Garner like this:
get do
garner.options(expires_in: 15.minutes) do
locations = Location.includes([:organization, :services]).page(params[:page]).per(params[:per_page])
locations.extend LocationsRepresenter
end
endOn the first request, I get the full representation. On the garnered request, I get the non-represented version of locations which is missing the organization and services stuff. I also tried garner.bind(Location) and garner.bind(Location).bind(Organization).bind(Service) and I'm still not getting the full representation back from garner.
If I try the same thing on an individual location:
get ':id' do
garner.options(expires_in: 15.minutes) do
location = Location.includes([:organization, :services]).find(params[:id])
location.extend LocationRepresenter
end
endI get can't dump anonymous class #<Module:0x007f875130b3f0>.
I get the same dump error with the bind method:
get ':id' do
garner.bind(Location) do
location = Location.includes([:organization, :services]).find(params[:id])
location.extend LocationRepresenter
end
endAny help would be greatly appreciated! Thanks!