I am trying to change the cookie for the location of users in the front filter, but I am having problems:
A cookie is set to 1 correctly if it does not exist but is not permanently stored and returns to 1 for any subsequent requests.
def remember_location(loc = nil)
cookies.permanent[:location] = 1 if cookies[:location].nil?
loc = Location.find(loc).try(:id) rescue nil
unless loc.nil?
cookies.permanent[:location] = loc
end
cookies[:location]
end
source
share