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

The cookie bar doesn't want to disappear definitely when I click on the OK button #84

Open
Bertrand-Bichat opened this issue Jul 15, 2020 · 11 comments

Comments

@Bertrand-Bichat
Copy link

I have the same problem in production and development environment. When I click on the cookies_eu button "OK", the cookie bar disappears as expected. But if I go to another page of my website, sometimes the cookie bar appears again. Where is the problem ? I use Ruby 2.6.5 and Rails 5.2.4.1

@eshaam
Copy link

eshaam commented Aug 23, 2020

Same issue

@GregoireMorane
Copy link

Same issue (ruby 2.6.6)

@Bertrand-Bichat
Copy link
Author

Bertrand-Bichat commented Sep 15, 2020

I use Ruby 2.6.6 now, same issue. I don't use turbolinks.

I think it comes from the file '_consent_banner.html.erb' in views. There is this line to know if cookie bar is display or not :
<% if cookies && cookies['cookie_eu_consented'] != "true" %>

The problem is : 'cookies' variables is equal to a symbol :page (or :pages), so cookies['cookie_eu_consented'] is always equal to nil. How can I managed cookies to set cookies['cookie_eu_consented'] at true ? Is turbolinks mandatory ? I have seen this issue, but nothing works with me : #73

@frikkl
Copy link

frikkl commented Sep 27, 2020

Hello community,
i had the same problem, but i finally found a easy solution here:
https://discuss.rubyonrails.org/t/js-cookie/73808

terminal:
yarn add js-cookie
app/javascript/packs/application.js
window.Cookies = require("js-cookie")

@martinbarilik
Copy link

@frikkl it doesnt work for me tho ... I think the js-cookie is the completely different thing from cookies-eu

@gabskoro
Copy link
Collaborator

gabskoro commented Oct 2, 2020

Sorry guys, but I just can't reproduce it. Can someone pls share me a boilerplate where I can reproduce it? I'm now testing it on Rails 5 and 6, works fine :(

@ghost
Copy link

ghost commented Nov 3, 2020

Same issue. I just checked the browser console and found some error there.
Uncaught TypeError: Turbolinks.clearCache is not a function

@martinbarilik
Copy link

It seems you have a problem with turbolinks, not cookie bar. Can you share a code where you use .clearCache function ?

@ghost
Copy link

ghost commented Nov 3, 2020

I just integrated the gem. No external js is added for same.
Turbolinks.clearCache(), its already defined in gem's javascript file.
f497dd7#diff-8c3d240d047cd715dd245b524045d31bf6ec42867d418d145da6f471c8bfaa28.

Any suggestion to fix this, will be really helpful!
Thanks.

@martinbarilik
Copy link

Do you use turbolinks in you Rails app ? What rails version do you have ?

@ghost
Copy link

ghost commented Nov 3, 2020

I am using rails 4.2.6. Yes,Turbolinks used in my application.

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

6 participants