Use cattr_accessor directly inside the defined class, otherwise in Rails 5 this accessor returns nil.