Reputation: 1147
impressionist(@object, nil, unique: [:session_hash])
Calling impressionist() inserts the record first time, later on every request it says Record Already Exist because it always find Nil value for session_hash. it looks it does not log the rails-4 session value into "session_hash".
I'm using Rails 4.1.6, ruby 2.1.3p242 and impressionist (1.5.1)
Any help on this ?
Upvotes: 1
Views: 306
Reputation: 1
I think the issue you're describing is the same as mine and I found the solution under this open issue on the git repo.
https://github.com/charlotte-ruby/impressionist/issues/177
You have to override the session hash method for your project to initialise the session before making a request for the id.
ImpressionistController::InstanceMethods.class_eval do
def session_hash
session[:init] = true
request.session.id
end
end
Upvotes: 0
Reputation: 379
I ran into the same issue. I ended up using a conditional statement checking whether the session_hash exists.
if session_hash.blank?
impressionist(@object)
else
impressionist(@object, nil, unique: [:session_hash])
end
Upvotes: -1