Fixed allow_nil issue in rails 3.1 later release