1

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

1 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

1 Comment

Yup the text says it iself, it is a matter of interpretation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.