> #actionize seems useful, if only to have a more readable method for
> using existing functionality.
>
> i guess i could say the same about #parameterize, except that its
> function is to make a string url-safe, in a very generic way, and
> there are already methods (with appropriate naming, this time) which
> do that, right?
>
> http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Inflections.html#M000481
>
> ActiveSupport::CoreExtensions::String::Inflections::underscore()
>
> is the same thing, I take it?
Also mirrored from Lighthouse:
#underscore and #parameterize differ in how they handle spaces and
special characters.
>> "Donald E. Knuth".underscore
=> "donald e. knuth"
>> "Donald E. Knuth".parameterize
=> "Donald_E_Knuth"
It seems that #underscore expects a camelcased string, not a more
human-readable one.
#actionize is like #tableize, but it replaces spaces with underscores
(by default), and doesn't pluralize the output.
>> "Expense Report".tableize
=> "expense reports"
>> "Expense Report".actionize
=> "expense_report"
I thought there was already something that did that, but maybe I just
combined a couple other ones to do it....
> @reports.each do |report_name|
> link_to(report_name, "/reports/#{report_name.actionize}")
> end
> # => "<a href = '/reports/expense_report'>Expense Report</a>
> <a href = '/reports/employee_hours'>Employee Hours</a>"
Is that really the HTML that link_to generates? Is it legal HTML to have
those spaces around the =? (I don't like the single-quotes either, but
I'm pretty sure they're legal.)
> Parameterize
>
> Replaces special characters in a string so that it may be used as part
> of a 'pretty' URL.
> # => <a href="/person/1-Donald_E_Knuth">Login</a>
My understanding is that for SEO purposes, hyphens are actually better
than underscores for separating words, because search engines consider
underscores as part of a word (either thanks to PCRE's \w regex, or a
desire to cater to programmers, I'm not sure which). It seems to be a
point of active (mild) controversy though.
--
==============================| "A microscope locked in on one point
Rob Funk <rf...@funknet.net> |Never sees what kind of room that it's in"
http://www.funknet.net/rfunk | -- Chris Mars, "Stuck in Rewind"
>
> Matt Darby wrote:
>> Actionize
> I thought there was already something that did that, but maybe I just
> combined a couple other ones to do it....
>
> Is that really the HTML that link_to generates? Is it legal HTML to
> have
> those spaces around the =? (I don't like the single-quotes either,
> but
> I'm pretty sure they're legal.)
>
>
>> Parameterize
> My understanding is that for SEO purposes, hyphens are actually better
> than underscores for separating words, because search engines consider
> underscores as part of a word (either thanks to PCRE's \w regex, or a
> desire to cater to programmers, I'm not sure which). It seems to be a
> point of active (mild) controversy though.
Hi Rob!
Actionize:
Jim brought up the same thoughts about this in Lighthouse ticket.
#actionize is similar to #tableize, but without the pluralization and
that it also treats spaces differently. I kind of half-assed guessed
what #link_to actually generates, but you get the point ;)
Parameterize:
I think you might be right on the SEO point, I should probably make
that the default separator.
Thanks for your thoughts; I use these (very simple) Inflectors in my
everyday code, I thought they might be helpful to Others.