3

I am trying to use grape-entity without the grape-api gem. So just use it as a serializers for raw rails controllers.

When trying to present my resource by doing:

present User.all, with: Entities::User

I get that the present method is undefined

How am I suppose to present those resources using the entity? The documentation says to use present

Hommer Smith
  • 26,772
  • 56
  • 167
  • 296

1 Answers1

4

I needed to use Grape Entity as well, outside of Grape (in a basic Rails controller), and I ended up using Chris suggestion:

Entities::MyResource.represent MyResource.first

It works like a charm, thanks!

Francesco Meli
  • 2,484
  • 2
  • 21
  • 52
  • Additional tip: Once you have an instance of the entity representing the object, you can call `serializable_hash` on it – Allison Sep 04 '20 at 07:04