Away Rails on the road I stumbled upon an interesting post by Err the blog: a nice trip through ActiveSupport, the component of Rails that takes care of extending Ruby's default library.
I'm also posting this here to avoid wasting time every time I look for the right method of Inflector
:
>> "reindeer".pluralize
=> "reindeers"
>> "elves".singularize
=> "elf"
> "christmas_carol".camelize
=> "ChristmasCarol"
> "christmas_carol".camelize(:lower)
=> "christmasCarol"
> "holiday_cheer".titleize
=> "Holiday Cheer"
> "AdventCalendar-2006".underscore
=> "advent_calendar_2006"
> "santa_Claus".dasherize
=> "santa-Claus"
> "Holiday::December::Christmas".demodulize
=> "Christmas"
> "SnowStorm".tableize
=> "snow_storms"
> "snow_storms".classify
=> "SnowStorm"
> "present_id".humanize
=> "Present"
> "Present".foreign_key
=> "present_id"
>> "cheer".constantize
NameError: uninitialised constant Cheer
>> "Christmas".constantize
=> Christmas
Previous
December 18, 2006
Next
December 20, 2006
I am Silvano Stralla. I am a developer, I like taking photos and riding bikes.
If you want, you can write to me at silvano.stralla at
sistrall.it.
This site is handmade, with love, in Turin (Italy).
© 2002—2024 Silvano Stralla
This page was built on Thu, 21 Nov 2024 14:26:57 GMT from code version 7134da1a.