Ring codes