-
Notifications
You must be signed in to change notification settings - Fork 24
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
Where to include Garner::Mixins::Rack ? #53
Comments
Same with the Mongoid mixins. I created module Mongoid
module Document
include Garner::Mixins::Mongoid::Document
end
end but it complains: |
I also tried Grape::Endpoint.send :include, LinkHeader, Garner::Cache::Context However, I had some strange things happen. With the resource 'categories' do
# GET /categories
desc "Returns all categories"
params do
optional :page, type: Integer, default: 1
end
get do
garner.options(expires_in: 1.hour) do
categories = Category.page(params[:page]).per(400)
categories.extend CategoriesRepresenter
end
end
end However, if I change the time to |
@monfresh: Thanks for your issue! In response to the first point,
the issue is that you need to explicitly
Yes, I agree. For a Grape application, I'd include the Garner mixin using module API
class Root < Grape::API
helpers Garner::Mixins::Rack
# ...
end
end and module Ohana
class API < Grape::API
helpers Garner::Mixins::Rack
# ...
end
end I'll draft an edit to the README that references the Grape integration details. |
This point is a bit trickier to debug with certainty:
Can you send the complete backtrace? It seems as though the cache store is correctly marshaling and caching the To this point:
Are you looking to get 304 response codes for class API < Grape::API
use Rack::ConditionalGet
use Rack::ETag
end |
Thanks for your detailed responses. I got the mixins working, but I think I found a reproducible case for
get do
garner.options(expires_in: 15.minutes) do
categories = Category.page(params[:page]).per(400)
categories.extend CategoriesRepresenter
end
end
Expected Result: a 200 response If I wait a few minutes and try again, it starts working again. The same thing happens if I uncomment the garner block and try right after doing it.
|
It seems like any change you make to the garner block results in a 500. It's probably not unmarshalling like you suspected. Is there something I can do to force it to unmarshal? |
Quick unrelated question: garner.bind(Location.identify(params[:id])) do
location = Location.find(params[:id])
end equivalent to this? location = Location.garnered_find(params[:id]) |
Those two calls are nearly equivalent. The only difference is that |
@monfresh: I tried unsuccessfully to reproduce the bug you're seeing in 9c87cf4. The stopping/starting of the Grape server is the hard part to simulate in a spec. Have you seen the bug manifest itself in other ways, without stopping/starting the server? Alternatively, do you have suggestions for how to test this in an RSpec environment? |
Hi,
I'd like to try this gem out, but I can't get it to recognize the mixin in my Rails app. It would be great if the documentation were more specific as to where the include needs to go. Here is my setup:
app/api/api.rb:
app/api/ohana.rb:
I tried including it in both files, and also in the
Grape::Endpoint.send
line, but I keep gettinguninitialized constant Garner::Mixins
. What am I doing wrong?The text was updated successfully, but these errors were encountered: