hanami / utils

Ruby core extentions and class utilities for Hanami

Home Page:http://hanamirb.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong inflections on irregular words when prefixed

TiteiKo opened this issue · comments

I have a route resource :satisfaction_quizzes

Generated route for :show is named satisfaction_quizze instead of satisfaction_quiz

I'll just add an exception to the inflector, but is having a prefix to an irregular word a common enough occurence so that it should be handled by the inflector?

@TiteiKo have you tried a resource named :quizzes? to show what happen with the singular.

@AlfonsoUceda works well without the prefix:

On a clean app, adding the following routes:

resources :quizzes, only: [:index, :show]
resources :prefix_quizzes, only: [:index, :show]

produces the following:

→ bundle exec hanami routes
                Name Method     Path                           Action

             quizzes GET, HEAD  /quizzes                       Web::Controllers::Quizzes::Index
                quiz GET, HEAD  /quizzes/:id                   Web::Controllers::Quizzes::Show
      prefix_quizzes GET, HEAD  /prefix_quizzes                Web::Controllers::PrefixQuizzes::Index
       prefix_quizze GET, HEAD  /prefix_quizzes/:id            Web::Controllers::PrefixQuizzes::Show

It's weird because only the name of the route helper is wrong generated.

@TiteiKo thanks! I'll take a look at inflector internals tomorrow.

As we decided this should be treated as an exception on my side, I close this issue :)