I have certain user settings which I need to load when user logs in & destroy his custom settings after he logs out. I am using Devise gem. Also I intend to keep this settings record id in Rails session for easy access through out the application.
when the user logs out, I want to do something like this:
Setting.delete(session[:settings_id])
where Setting is my Model class, and I am holding the currently loaded settings_id in session as
session[:settings_id] = Settings.where(:conditions => hash).id
then when the user logs out, I will have to delete the record from my settings table using
Setting.delete(session[:settings_id]),
since I already have currently loaded settings_id kept in session. How can I do it alongside Devise ?
Devise is build upon warden which provides some callbacks you may use: