Skip to content

Instantly share code, notes, and snippets.

@gambala
Created July 24, 2017 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gambala/df0ed4f892c88e1f456f9a78df6750a5 to your computer and use it in GitHub Desktop.
Save gambala/df0ed4f892c88e1f456f9a78df6750a5 to your computer and use it in GitHub Desktop.
Redis::Objects use case
p = user.ip_addresses.size
p = user.ip_addresses.value
class ApplicationController < ActionController::Base
before_action :store_ip_addresses
def store_ip_addresses
return unless user_signed_in?
current_user.ip_addresses << request.ip
end
end
class User < ApplicationRecord
include Redis::Objects
set :ip_addresses
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment