Ruby on Rails, issues using enum with same name Ruby on Rails, issues using enum with same name ruby ruby

Ruby on Rails, issues using enum with same name


You can use the :_prefix or :_suffix options when you need to define multiple enums with same values. If the passed value is true, the methods are prefixed/suffixed with the name of the enum. It is also possible to supply a custom value:

class Conversation < ActiveRecord::Base  enum status: [:active, :archived], _suffix: true  enum comments_status: [:active, :inactive], _prefix: :comments end

source :http://edgeapi.rubyonrails.org/classes/ActiveRecord/Enum.html


First of all, just like the Marek Lipka said, you should use boolean value to handle your case.

If you need to define different enums with same entries, I suggest using the gem 'enumerize' (https://github.com/brainspec/enumerize) instead.