sistrall.it
Published on December 19, 2006

Journey in ActiveSupport

Hey, this post is vintage content. It dates back more than 17 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

Next

20 years later

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 Fri, 26 Jul 2024 20:16:11 GMT from code version 0b3cbb56.