Skip to content

Cannot annotate model with rails 4.1 enum #170

Closed
@alex88

Description

@alex88

Having this model:

class Team < ActiveRecord::Base
  # Gender enumerator
  enum gender: [:male, :female]
  # User ownership association
  belongs_to :owner, class_name: 'User'

  # Validations
  validates :name, :owner, presence: true
end

with a field gender of type integer, trying to annotate it gives:

Unable to annotate team.rb: You tried to define an enum named "gender" on the model "Team", but this will generate a instance method "gender=", which is already defined by another enum.

So I have to remove the enum thing in the model, run the annotation and add it back.

Is there a workaround for this?

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions