According to the
documentation<http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-humanize>
of
ActiveSupport::Inflector:
*humanize*(lower_case_and_underscored_word)
Capitalizes the first word and turns underscores into spaces and strips
a trailing “_id”, if any.
* Example: humanize("employee_salary") # => "Employee
salary"*
I would like to submit a pull request for *humanize *to accept a second
optional parameter that would allow the string to be *humanized without
being capitalized*.
*humanize*(lower_case_and_underscored_word, capitalize = true)
Turns underscores into spaces and strips a trailing “_id”, if
any". Capitalizes the first word if capitalize=true
* Example: humanize("employee_salary", false) # => "employee
salary"*
*
*
I have stumbled into cases where I want to "humanize" a word without
capitalizing it, and I''ve seen others
<http://pastebin.com/U3JSQ8AC>occurring in the same problem.
What is your opinion about this? Thanks
*
*
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to rubyonrails-core+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.
Xavier Noria
2013-Nov-06 17:45 UTC
Re: Feature: make capitalization optional in *humanize*
Sounds good to me. The documentation would say "if +capitalize+ is true", with "true" in regular font. Please update the AS guide as well if you are so kind. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.
Chad Woolley
2013-Nov-06 17:57 UTC
Re: Feature: make capitalization optional in *humanize*
+1, I was just wishing for this last week :) On Wed, Nov 6, 2013 at 10:45 AM, Xavier Noria <fxn@hashref.com> wrote:> Sounds good to me. > > The documentation would say "if +capitalize+ is true", with "true" in > regular font. Please update the AS guide as well if you are so kind. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscribe@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/groups/opt_out. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.
Tomas Varneckas
2013-Nov-06 18:08 UTC
Re: Feature: make capitalization optional in *humanize*
Boolean arguments are really cryptic in most cases.
Perhaps you should add an options hash instead?
E.g:
humanize("employee_salary", capitalize: false)
On Wed, Nov 6, 2013 at 7:57 PM, Chad Woolley
<thewoolleyman@gmail.com>wrote:
> +1, I was just wishing for this last week :)
>
>
> On Wed, Nov 6, 2013 at 10:45 AM, Xavier Noria <fxn@hashref.com>
wrote:
>
>> Sounds good to me.
>>
>> The documentation would say "if +capitalize+ is true", with
"true" in
>> regular font. Please update the AS guide as well if you are so kind.
>>
>> --
>> You received this message because you are subscribed to the Google
Groups
>> "Ruby on Rails: Core" group.
>> To unsubscribe from this group and stop receiving emails from it, send
an
>> email to rubyonrails-core+unsubscribe@googlegroups.com.
>> To post to this group, send email to rubyonrails-core@googlegroups.com.
>> Visit this group at http://groups.google.com/group/rubyonrails-core.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-core+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at http://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to rubyonrails-core+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.
Tomas Varneckas, I see your point!
Xavier Noria… do you agree as well? I think it reads better:
humanize("employee_salary") # => "Employee salary"
humanize("employee_salary", capitalize: false) # =>
"employee salary"
On Wednesday, November 6, 2013 10:08:54 AM UTC-8, Tomas Varneckas
wrote:>
> Boolean arguments are really cryptic in most cases.
> Perhaps you should add an options hash instead?
>
> E.g:
> humanize("employee_salary", capitalize: false)
>
>
> On Wed, Nov 6, 2013 at 7:57 PM, Chad Woolley
<thewoo...@gmail.com<javascript:>
> > wrote:
>
>> +1, I was just wishing for this last week :)
>>
>>
>> On Wed, Nov 6, 2013 at 10:45 AM, Xavier Noria
<f...@hashref.com<javascript:>
>> > wrote:
>>
>>> Sounds good to me.
>>>
>>> The documentation would say "if +capitalize+ is true",
with "true" in
>>> regular font. Please update the AS guide as well if you are so
kind.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ruby on Rails: Core" group.
>>> To unsubscribe from this group and stop receiving emails from it,
send
>>> an email to rubyonrails-co...@googlegroups.com <javascript:>.
>>> To post to this group, send email to
rubyonra...@googlegroups.com<javascript:>
>>> .
>>> Visit this group at
http://groups.google.com/group/rubyonrails-core.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google
Groups
>> "Ruby on Rails: Core" group.
>> To unsubscribe from this group and stop receiving emails from it, send
an
>> email to rubyonrails-co...@googlegroups.com <javascript:>.
>> To post to this group, send email to
rubyonra...@googlegroups.com<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/rubyonrails-core.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to rubyonrails-core+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.
Xavier Noria
2013-Nov-06 20:23 UTC
Re: Feature: make capitalization optional in *humanize*
On Wed, Nov 6, 2013 at 9:06 PM, Claudio B. <claudiob@gmail.com> wrote: Tomas Varneckas, I see your point!> > Xavier Noria… do you agree as well? I think it reads better: > > humanize("employee_salary") # => "Employee salary" > > humanize("employee_salary", capitalize: false) # => "employee salary" >Good! -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.
Pull request sent! http://github.com/rails/rails/pull/12789 On Wednesday, November 6, 2013 12:23:31 PM UTC-8, Xavier Noria wrote:> > On Wed, Nov 6, 2013 at 9:06 PM, Claudio B. <clau...@gmail.com<javascript:> > > wrote: > > Tomas Varneckas, I see your point! >> >> Xavier Noria… do you agree as well? I think it reads better: >> >> humanize("employee_salary") # => "Employee salary" >> >> humanize("employee_salary", capitalize: false) # => "employee salary" >> > > Good! > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.