Published on December 19, 2006
Journey in ActiveSupport
Hey, this post is vintage content. It dates back more than 18 years ago: it may contain outdated and inaccurate information.
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
Globalyses and symbols for date formats
December 18, 2006
Next
20 years later
December 20, 2006