Skip to content
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

AS gets confused with enums. #474

Closed
ConfusedVorlon opened this issue Jan 27, 2016 · 2 comments
Closed

AS gets confused with enums. #474

ConfusedVorlon opened this issue Jan 27, 2016 · 2 comments

Comments

@ConfusedVorlon
Copy link

to be fair - I get confused with rails enums as well...

In my model, I have the following enum:

`enum message_type: { unspecified: 0, activity: 10, personal: 50, announcement: 70, nothing: 100 }``

in the database, this column is a simple integer

t.integer :message_type, null: false, default: 0

Active scaffold correctly shows me the symbol in the 'show' column (e.g. if the db has 10, it shows me 'activity')

However, in the edit column, it gives me a numeric field which is incorrectly pre filled with text instead of the number.

<input name="record[message_type]" class="message_type-input numeric-input text-input" id="record_message_type_54" autocomplete="off" format="i18n_number" type="number" value="activity">

ideally, AS would do some magic, spot that this is an enum, and provide the update field as a select with the enum symbol values. Failing that, if I had to tell rails that the column was an enum to trigger the same behaviour- that would be the next best thing.

thanks for a fantastic project.

@scambra
Copy link
Member

scambra commented Feb 3, 2016

Enums are new to rails 4.1 or 4.2, IIRC, and ActiveScaffold needs support for them

@ConfusedVorlon
Copy link
Author

thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants