Advantages of choosing Ruby on Rails for your Startup !

Posted on by tkwong

This was a post that was long pending that we wanted to write but somehow assumed that all would know fair and square. Anyway we are putting it in words here for the benefit of the entrepreneurs and the startup community . Ruby on Rails has come a long way from its inception and with Rails 3 we can clearly define the value differentiator of Ruby on Rails in comparison with conventional technologies.

1. With Ruby on Rails a Quick transformation of concepts to code is possible.
2. Rapid framework building capable. Building the basic product can be very fast on ROR
3. Incremental integration is possible as there is a structured framework
4. Testing of code of errors is integrated as part of the process.
5. Possible to reduce your lead time from configuration setting to application deployment by more than 40%.
6. Build on ROR is lean and mean very compatible for mobile devices of the future.
7. Your product is future ready for emerging trends to build mobile solutions and cloud models.
8. Capitalise on the benefits of Opensource with strong online community presence that constantly refines code.
9. ROR is best suited for BDD and Agile environment where value creation is the top priority for a project

Ray Lee liked this post

Paperclip: migrating from Amazon S3 to file system storage

Posted on by tkwong

Long has a problem to migration filesystem attachment to S3 and several articles already explain.

For today I just head on the problem that in reverse..  Here is my code snippet :

    require 'aws/s3'
    require 'fileutils'

    # Assume the original s3 paperclip option is {:storage => :s3, :s3_protocol => 'https',:s3_headers => {'Expires' => 1.year.from_now.httpdate},:s3_credentials => "#{Rails.root.to_s}/config/amazon_s3.yml", :path => '/:class/:attachment/:id/:style/:filename'}
    # New paperclip options is {:storage => :filesystem, :url => '/system/:class/:attachment/:id/:style/:filename'}

    # Load credentials
    s3_options = YAML.load_file(File.join(Rails.root, 'config/amazon_s3.yml'))["production"].symbolize_keys
    bucket = s3_options.delete(:bucket)

    # Establish S3 connection

    { 'Product' => :image, 'Product' => :icon }.each do |klass_name,param|
      klass = klass_name.constantize
      # Process each attachment
      styles = klass.first.send(param).styles.keys.push(:original)

      klass.all.each_with_index do |obj, n|
        styles.each do |style|
          filesystem_path = obj.send(param).path(style)

          next if filesystem_path.blank? 

          s3_path = filesystem_path.gsub(/^.*\/system/,'')

          # File System Path => '/system/:class/:attachment/:id/:style/:filename'
          # S3 path => '/:class/:attachment/:id/:style/:filename'


            # Create Directory
            FileUtils.mkdir_p  File.dirname(filesystem_path)

            # Write File (from S3 path to filesystem path)
  , "wb") do |f|
              f.write(AWS::S3::S3Object.value(s3_path, bucket))
          rescue Exception => e
            puts e
        puts "#{klass_name} Saved to #{filesystem_path} (#{n}/#{klass.count})"

also available in .

Ray Lee liked this post

Rails 3.0.9 has released

Posted on by tkwong

Hi everybody!

Rails 3.0.9 has been released! I think i will have a try and post the latest updates after my test run. The main fixed in this release are problems dealing with modifications of SafeBuffers.gem install rails or update your Gemfile and bundle update while it’s hot!


The major changes in this release of Rails are bug fixes surrounding modifications to SafeBuffer strings. We had places that were modifying SafeBuffers and those places raised exceptions after the security fixes in the 3.0.8 release.

We’ve since updated those code paths, and now we have this nice release for you today!

Please check the CHANGELOG files in each section on github for more details.

For an exhaustive list of the commits in this release, please see github. Please enjoy this release of Rails!

Ray Lee liked this post

Coffee-script in Rails 3

Posted on by tkwong

Since Rails 3.1 will have coffee-script as default. For those eager to try it can easily do so with ‘barista’ gem.

Simply head to:

Textmate bundles:



Rails 3 date_formats.rb in initializers

Posted on by tkwong
# Rails 2
# config/initializers/date_formats.rb
:standard => '%d %b %Y',
:default => '%d %b %Y',
:standard_time => '%d %b %Y %H:%M'

# Rails 3
# config/initializers/date_formats.rb
:standard => '%d %b %Y',
:default => '%d %b %Y',
:standard_time => '%d %b %Y %H:%M'