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

Add support for selectable strings on edit pages #422

Closed

Conversation

Jberlinsky
Copy link
Collaborator

This pull request adds support for collection select fields, much like simple_form's collection: [:foo, :bar] option. This also provides a base field that will be helpful in implementing the HasOne field that is currently pending implementation.

Example User Story

As a developer
I want to allow administrative users to select values from a drop-down rather than enter them free-form
So that I don't need to worry quite as much about data integrity in my administrative interface
And so that my users have a streamlined user experience.

[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Select
%>

<%= field.data.presence %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the .presence necessary? I would expect it to behave the same without it, because the result is getting rendered as a string either way.

@c-lliope
Copy link
Contributor

I really like this! I left a few small comments.

@@ -4,6 +4,11 @@ class Customer < ActiveRecord::Base
validates :name, presence: true
validates :email, presence: true

KINDS = [

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Freeze mutable objects assigned to constants.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This array is frozen -- Hound isn't catching that it's a couple lines down.

@Jberlinsky Jberlinsky force-pushed the jb-dropdown-selection-field branch from a03bc27 to 2ac9189 Compare March 17, 2016 05:45
@Jberlinsky
Copy link
Collaborator Author

@Graysonwright Addressed your concerns; will squash whenever you're ready.

@c-lliope
Copy link
Contributor

Looks great! Merged in as 3bccdb3.

@c-lliope c-lliope closed this Mar 29, 2016
@pedantic-git
Copy link
Contributor

Hm - this conflicts with my gem https://rubygems.org/gems/administrate-field-select and is missing some of the features of that gem. I'll rename the class in my gem so it doesn't conflict but perhaps we can work together to merge the two concepts into one at some point?

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

Successfully merging this pull request may close these issues.

4 participants