-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate field names when using ActiveHash::Enum #322
Comments
Has anyone tested what happens with active record's version of enum? |
I tested this with ActiveRecord's version of enum. Since field_names doesn't exist in ActiveRecord, I used column_names instead. # == Schema Information
#
# Table name: events
#
# id :uuid not null, primary key
# name :string not null
# status(draft, published, archived) :string not null
# created_at :datetime not null
# updated_at :datetime not null
#
class Event < ApplicationRecord
enum :status, { draft: "draft", published: "published", archived: "archived" }
end bin/rails c
Loading development environment (Rails 7.1.4)
[1] pry(main)> Event.column_names
=> ["id", "name", "status", "created_at", "updated_at"] |
Thanks. I'll put my comments over in the pr. Update: oops. This is in response to comments in the other PR. Thanks for documenting. Yea, so the question mark methods work fine in rails and they find do the constants, so don't have this issue as well. |
Environment
Ruby version: 3.3.4
ActiveHash version: 3.3.1
Description of the issue
When using
ActiveHash::Enum
in combination withActiveHash::Base
, thefield_names
method returns duplicate field names. This occurs only whenenum_accessor
is used.Steps to reproduce
Example code
Expected behavior
The field_names method should return unique field names:
Additional information
This issue does not occur when ActiveHash::Enum is included without using enum_accessor:
The text was updated successfully, but these errors were encountered: