-
Notifications
You must be signed in to change notification settings - Fork 310
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
NoMethodError (undefined method `cookie_value' for nil:NilClass) in API only Rails project #292
Comments
Yes, I'm having the same error but in a standard Rails App. The gem was working fine in my Film model, updating the impressions correctly, but suddenly I get the undefined method 'cookie_value' for "60cb104e4befe185a8b81aac9a2c5e3c":String It seems like it has something to do with the session_hash. impressionist (2.0.0) app/controllers/impressionist_controller.rb:143:in Not sure how to solve this. Would appreciate any insights. |
Hi @rzjfr unfortunately this doesn't seem to be working for me. I installed your version of the gem and I'm getting this error:
When I print
|
Hey @rzjfr just attached the Gemfile.lock (renamed to Gemfile.lock.txt because of GitHub filetype restrictions). I had to lightly edit it to remove a couple of private gems and sources, but I didn't change much. It could just be caused by a strange configuration on our side. So if it's working for other API only apps then don't worry about closing this issue if you think that's the case. @lusinh I tried your branch as well. Got the same error, the error seems to be happening before all the lines both of you edited |
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. |
Error still persists. |
I had a same problem and downgraded gem version, and then solved it! gem 'impressionist', '~> 1.6.1' |
Same issue here with rails 6 |
Issue still exists # Quick fix
def show
...
if session.id.present?
impressionist @question, nil, unique: %i[impressionable_type impressionable_id session_hash]
end
end |
Hey @stadniklksndr the problem of your solution is that we lost the tracking for that users. |
Me, too. I've got this error message. |
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
fromrequest.session_options[:id]
, which isnil
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:
The text was updated successfully, but these errors were encountered: