Action Controller Tweaks

ActionController is great, but could be better. Here are some tweaks for it.


GitHub Build Status

Gem Version License

Coverage Status Code Climate

The above badges are generated by


gem 'action_controller_tweaks'


Either include it in specific controller or just ApplicationController

class SomeController
  include ActionControllerTweaks


I got the code from This Stack Overflow Answer
#expires_now is not good enough when I test a mobile version page with Chrome on iOS

  # Just like using #expires_now

#set_session & #set_session_with_expiry

I write this on my own, it's ok to blame me if it's buggy :P
This method let's you set session, with expiry time!
It depends on before_action to remove expired session keys
Valid options: expire_in, expires_in, expire_at, expires_at Example:

# Option keys are NOT checked
set_session(:key, 'value') # => Just like session[:key] = 'value'

set_session(:key, 'value', expire_in:
set_session(:key, 'value', expires_in:

set_session(:key, 'value', expire_at:
set_session(:key, 'value', expires_at:

# Option keys are checked
# You must pass valid options or error will be raised
set_session_with_expiry(:key, 'value', expires_in:

Note: Please don't use the session key session_keys_to_expire, it's reserved for internal processing