-
Notifications
You must be signed in to change notification settings - Fork 68
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
set scope from params #13
Comments
I think there isn't a way to do this currently. I think what this needs is an alternative syntax for configuring GAMS. The way I was thinking of is having a get ':id' do
render json: Movie.find(params[:id]), scope: { showings: params[:showings] }
end This should solve your problem as it would bring params in scope. Thoughts? |
+1 for this, i have an api which need to present results from sunspot search. i want to include a meta like { total: search.total } |
I was planning on doing this but my laptop has died and is in for repair. If you want to pick it up and submit a PR feel free otherwise it will e a couple of weeks. Kind regards, Sent from my phone.
|
Thanks, @jrhe . Happy new year! i found a workaround using Grape's present. looks like not a bad solution. |
Could you post your solution here? It might be the same syntactic sugar I On 2 January 2014 08:38, 来诺 [email protected] wrote:
|
i was just using grape's present method something like
song_search.results is a collection of Song model instances |
Would love to see something like this 👍 |
As in issue ruby-grape#13 an example solution provided by @jrhe an implementation of said feature has been created. As per the discussion in the thread this is only a helper to be able to reach the available options provided in the active_model_serializer gem. usage is as follows: ```ruby get '/some_path' do collection = Collection.all render collection, { meta: { current_page: 5 }, meta_key: :pagination_info } end ``` The return value would be: `{ pagination_info: { current_page: 5 }, collection: [item, item] }` If given without a `meta_key` it would return as: `{ meta: { current_page: 5 }, collection: [item, item] }` Any feedback appreciated. @zph, @olleolleolle and @bjoska
As in issue ruby-grape#13 an example solution provided by @jrhe an implementation of said feature has been created. As per the discussion in the thread this is only a helper to be able to reach the available options provided in the active_model_serializer gem. usage is as follows: ```ruby get '/some_path' do collection = Collection.all render collection, { meta: { current_page: 5 }, meta_key: :pagination_info } end ``` The return value would be: `{ pagination_info: { current_page: 5 }, collection: [item, item] }` If given without a `meta_key` it would return as: `{ meta: { current_page: 5 }, collection: [item, item] }` Any feedback appreciated. @zph, @olleolleolle and @bjoska
* 'master' of github.com:jrhe/grape-active_model_serializers: fix: when resource is empty, keep json resource root support active model serializer 0.9.x [Issue #13] Add render syntactic sugar
I need to set the serializer scope from the params, I'm trying like that:
but params is not yet defined.
Is there way to do that?
The text was updated successfully, but these errors were encountered: