Reputation: 4526
I am using ActiveRecord
enums in my Rails app that is version 4.1.4. I have a enum on the status
column of my Message
model. When I attempt to use the helper method statuses
to see all of the available statuses I get the error: You tried to define an enum named "status" on the model "Message", but this will generate a class method "new", which is already defined by Active Record.
The Message
model belongs_to
two other models, but that isn't the issue because I commented out the relationship and it still presented the error. I cannot seem to find anyone else having this issue.
class Message < ActiveRecord::Base
belongs_to :user
belongs_to :contact
enum status: %w(new assigned archived)
end
Upvotes: 1
Views: 1260
Reputation: 4526
Wow I really wasnt thinking here, I was attempting to use the enum value new
which is a class method so I therefore cannot define a new method using enum status: [:new]
. I just had to change it to unassigned
Upvotes: 6