views:

465

answers:

2

I want to use the Date::ABBR_MONTHS constant in my rails application. I see the Ruby stdlib documentation at http://www.ruby-doc.org/stdlib/ which does not seem to have this constant. However, this constant is there at http://stdlib.rubyonrails.org/

What is the difference between these two libraries?

This constant is working on my unix deployment machine but not on my dev machine on windows. Can anybody explain whats going on?

+2  A: 

ABBR_MONTHS is something you get given to you by ActiveSupport and it's just added into the Date class. The first library is for ruby, where the second one is for ruby on rails. The constant may not be working because of different versions of Rails.

Ryan Bigg
+1  A: 

ABBR_MONTHS is added to Date by ActiveSupport.

Rails is in fact a set of a few gems. ActiveSupport's role is mostly to add niceties to the Ruby language and other agnostic tools like the Inflector and the 2.days way of creating Time instances and so on.

So if you need this kind of capability outside of your rails app for some reason, you're in luck:

require 'rubygems' #If not already done
require 'activesupport'
puts Date::Format::ABBR_MONTHS.inspect
#=> {"oct"=>10, "jul"=>7, "jan"=>1, "dec"=>12, "jun"=>6, "apr"=>4, "feb"=>2, "may"=>5, "sep"=>9, "aug"=>8, "mar"=>3, "nov"=>11}
webmat