calebhearth / formulaic

Simplify form filling with Capybara

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reliance on human_attribute_name does not work with plural model classes

derekprior opened this issue · comments

I have an ActiveModel class named Credentials with encapsulates an email and password form. I define the following translations:

---
en:
  activemodel:
    attributes:
      credentials:
        email: Email Address
        password: Password

However, when I call fill_form(:credentials, { email: 'foo@bar.com', password: 'password' }, I get an InputNotFound error. Formulaic first tries to use simple form translations to find the input. Failing that, it tries to get at human attribute name by classifying the model name passed to fill_form. Unfortunately, classify uses the inflector to singularize the input.

I don't know if there's a great solution to this. I can't think of a scenario where the singularization would be useful for formulaic, but I also think reimplementing classify might be more trouble than its worth here as well.

For now, I can work around this by duplicating the translations as simple_form label translations, but this is also not an ideal solution.

adding inflect.uncountable 'credentials' to my inflections also fixes this and is likely a fine solution for this (even though its a lie). If you don't have a good idea for fixing this without the inflector, then feel free to close.