Make it work with active record