impressionist: NoMethodError (undefined method `cookie_value' for nil:NilClass) in API only Rails project
I’m getting the above error on my API only Rails project.
I think the issue is because we are running an API only Rails App without any cookies, and Impressionist is expecting to be able to retrieve the cookie_value
from request.session_options[:id]
, which is nil
for us.
Is there any way to handle this case without requiring cookies? Have I made a mistake here?
If not, would there be any interest in a PR to enable support for API only Rails projects without sessions? If so I’d be happy to implement this. Based on what I’ve seen it shouldn’t be too hard.
This is the full stack for the impressionist part of the error:
impressionist (2.0.0) app/controllers/impressionist_controller.rb:143:in `session_hash'
impressionist (2.0.0) app/controllers/impressionist_controller.rb:60:in `associative_create_statement'
impressionist (2.0.0) app/controllers/impressionist_controller.rb:132:in `direct_create_statement'
impressionist (2.0.0) app/controllers/impressionist_controller.rb:45:in `impressionist_subapp_filter'
impressionist (2.0.0) app/controllers/impressionist_controller.rb:7:in `block in impressionist'
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 11
- Comments: 16 (4 by maintainers)
Commits related to this issue
- Better nil guards from calling cookie value on nil or string [Fixes #292] — committed to rposborne/impressionist by deleted user 3 years ago
Issue still exists Had the same error in incognito mode and RSpec system tests
I had that issue when I tried to share url on facebook. Solution was to check if request is xhr. this was my solution and I don’t have that issue anymore
Hi @GraemeHarrison, no I don’t think I ever did. We ended up doing a simple version of what impressionist does in house in the end (basically a hook in the controller followed by saving requests to the DB) since it was good enough for our use case, so I haven’t used the gem since posting the issue.