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

ActiveAdmin should not use #titleize to generate controllers #980

Closed
tom-kuca opened this issue Feb 6, 2012 · 4 comments
Closed

ActiveAdmin should not use #titleize to generate controllers #980

tom-kuca opened this issue Feb 6, 2012 · 4 comments

Comments

@tom-kuca
Copy link

tom-kuca commented Feb 6, 2012

  ActiveAdmin.register ProductType do
     ...
   end

generates controller named ProducttypesController, expected controller name is ProductTypesController (note T is uppercase). I run into this when upgrading from 0.3.2 to 0.4.0

@tom-kuca
Copy link
Author

tom-kuca commented Feb 6, 2012

I figured out it's because I redefined titleize, so that it capitalizes only first letter. In czech language there is no habbit or rule to capitalize first letter of all words. From the documentation (http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-titleize)

titleize is meant for creating pretty output. It is not used in the Rails internals.

I believe ActiveAdmin also should not use titleize in its internals.

@yaychris
Copy link
Contributor

+1. Working on an app with a Dvd model, and my English locale is set to translate this to 'DVD' and 'DVDs', but titleize converts it to 'Dvd' and 'Dv Ds', respectively.

I expect my translations to appear in the interface exactly as I've specified in the locale file, with no additional processing. And, as @tom-kuca mentioned, this can cause issues with non-English languages.

@seanlinsley
Copy link
Contributor

I came across this Issue after getting fed up with a common frustration when using AA: very few non-alphanumeric characters can be used anywhere on the site because of the way it formats strings.

Doing a quick search through the source code, String::Inflections#titleize is called ~15 times... I'm tempted to override titleize, but I'm certain that would break something.

I would submit a bug fix to allow a configuration option in config/initializers/active_admin.rb which would let you either choose from a set of built-in string formats or let you define your own, but I'm not sure exactly how to go about doing that. I'll do the work if someone helps me along.

My thoughts are to define a custom string formatting method inside AA, which can easily be overridden if you require special formatting on your site.

@jpmckinney
Copy link
Contributor

Fixed by #1484

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

4 participants