daddyz / evercookie

evercookie gem for Ruby on Rails
MIT License
49 stars 27 forks source link

Struggling on setup Evercookie like dummy example #12

Open Frige1 opened 6 years ago

Frige1 commented 6 years ago

Hey,

i have some problems to setup a simple evercookie site pretty similar to the example dummy App.

If i start the Sever on Localhost:3000 i get the Index site and if i try to get oder set a Cookie, it fails. For example if i try to set a Cookie and sumbit the form i have some error in the console. (500 Internal Server Error - for etag, cache, auth, png) Furthermore i can see, that the set.js file does not contains any information from <%= @data[:key] -%>', '<%= @data[:value] -%> and this leads to ec.set('', '')

Versions: rvm - 1.29.4 (set rails as default) gem - 2.7.7 rails - 5.2.1 bundler - 1.16.2

daddyz commented 6 years ago

Are you using rails5 branch?

Frige1 commented 6 years ago

I wrote down the versions which I use for my testing. So , yes I using rails 5.

daddyz commented 6 years ago

@Frige1 I asked if gem was installed from rails5 git branch. Published version doesn't work on rails 5. Add this to your Gemfile

gem 'evercookie', github: 'daddyz/evercookie', branch: 'rails5'

My setup is the following. After successful signup page view has:

set_evercookie(:uid, current_user.id)

Registration form view has:

check_evercookie(:uid)

And controller action handling registration has:

ever_value = evercookie_get_value(:uid)

After signup I am setting signed up user ID. Since it's stored on client side on registration form I include helper that adds JS for fetching evercookie value and pass it to controller in order to save in session. And registration controller action checks session for value that was set in previous step. Hope it helps