Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I fetch request params inside an Entity ? #115

Closed
bilal62 opened this issue Mar 18, 2015 · 1 comment
Closed

How do I fetch request params inside an Entity ? #115

bilal62 opened this issue Mar 18, 2015 · 1 comment

Comments

@bilal62
Copy link

bilal62 commented Mar 18, 2015

Hello,

I'm trying to get the request params inside an Entity file. What is the best way to do that ?
The documentation says it should be in options[:env]['grape.request.params'] but it doesn't seem to work.
I could only get the params using options[:env]["rack.request.query_hash"] but I had to manually convert the number params to integers for me to be able to use them.
Is there a better way to get those params ?

@dblock
Copy link
Member

dblock commented Mar 19, 2015

I think you have to pass it into expose, something like this:

class Status < Grape::Entity
  expose :user do |instance, options|
    options[:request]
  end
end
present s, with: Status, request: request

You'll have better luck with questions on the Grape mailing list.

@dblock dblock closed this as completed Mar 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants