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

Incorrect inflection for param key of association ids #452

Open
laurenfackler opened this issue Oct 2, 2018 · 0 comments
Open

Incorrect inflection for param key of association ids #452

laurenfackler opened this issue Oct 2, 2018 · 0 comments

Comments

@laurenfackler
Copy link

For checkbox inputs of associations with unique pluralization requirements, e.g. specialty/specialties, ExAdmin incorrectly pluralizes the <association>_ids param key: specialtys.

In https://github.com/smpallen99/ex_admin/blob/master/lib/ex_admin/param_associations.ex#L34, if you replace

new_key =
  String.replace_suffix(key_as_string, "_ids", "s")
  |> String.to_atom()

with

key_as_string
  |> String.replace("_ids", "")
  |> Inflex.pluralize()
  |> String.to_atom()

it fixes the issue.

As a quick workaround, you can name the collection field so it takes the current pluralization logic, a simple prefix of s, into account. For example, instead of

inputs(:specialties, as: :check_boxes, collection: Repo.all(Specialty))

which will change the params key from specialty_ids to specialtys, you can do

inputs(:specialtie, as: :check_boxes, collection: Repo.all(Specialty))

which changes the params key from specialtie_ids to specialties, which is what's needed.

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

1 participant