Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use grape-entity without grape-api?

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

like image 984
Hommer Smith Avatar asked May 31 '26 10:05

Hommer Smith


1 Answers

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!

like image 149
Francesco Meli Avatar answered Jun 03 '26 01:06

Francesco Meli