Wednesday 7 April 2010

Rails / Ruby DateTime Stuff

A great blog entry: http://anandmuranal.wordpress.com/2007/12/12/formating-date-time-in-rails/

Tuesday 2 February 2010

Rails update a gem to an older version

You want say rack version 1.0.1 but the latest version is rack 1.1 and it's installed on your machine:

gem install [gem name] --version [version number]

For example:
gem install rack --version 1.0.1

Friday 20 November 2009

Getting Threads in Rails

So you want threads in rails? Add the following 2 lines to your production.rb file:

config.threadsafe!
config.eager_load_paths << "#{RAILS_ROOT}/lib"

For more reading, checkout: http://m.onkey.org/2008/10/23/thread-safety-for-your-rails

Tuesday 27 October 2009

Rails: Unpacking your gems into vendor/gems

Okay you have your marvelous gem but want to put it into the vendor directly.

No worries. In this example I will be working with the "marc (0.3.0)" gem.
  1. Edit the environment.rb file and under the "Rails::Initializer.run do |config|" put the following line: config.gem 'marc'
  2. Next "rake gems:unpack GEM=marc" where GEM=gem_name - don't worry about the version number.
All done. You should have a new directory under vendor/gems/gem_name.

Troubleshooting. If this doesn't quite work, you might want to try:
  • Create the gems directory under vendor yourself
  • It may complain that it lacks the specification file. If so go to the vendor/gems/gem_name directory and run: gem specification gem_name > .specification
If this still doesn't work ... then google or bing yourself to death.

Monday 26 October 2009

Viewing RDoc for installed gems

Pretty simple:

gem server

It's then available on localhost:8808

Pretty cool. It's like having available doc for JAR files. Sort of.