0

I am using STI on 'users' table with models. Users model has one enum 'gender' with values [:male, :female, :other].

#app/models/users.rb
class User < ApplicationRecord

  enum gender: {male: 0, female: 1, other: 3}

end

#app/models/employee.rb
class Employee < User

end

Last successful annotate result, also works if I remove enum from User class.

# == Schema Information
#
# Table name: users
#
#  id                     :integer          not null, primary key
#  email                  :string(100)      default(""), not null
#  encrypted_password     :string           default(""), not null
#  reset_password_token   :string
#  reset_password_sent_at :datetime
#  remember_created_at    :datetime
#  sign_in_count          :integer          default("0"), not null
#  current_sign_in_at     :datetime
#  last_sign_in_at        :datetime
#  current_sign_in_ip     :inet
#  last_sign_in_ip        :inet
#  created_at             :datetime         not null
#  updated_at             :datetime         not null
#  type                   :string
#  first_name             :string(100)      default(""), not null
#  last_name              :string           default("")
#

Running annotate throws following error:

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

gender in the only enum.

Using: ruby(2.4.0), rails(5.0.2), annotate(2.6.5)

Gaurav
  • 111
  • 2
  • 8

0 Answers0