Skip to content
How to print a document as a booklet
Posted 2002 days ago

After spending about an hour, reams of pages, and pails of ink, I finally stumbled into the magic of booklet printing. My source document was a MS-Word 2010 document with…

How to print a document as a booklet
Installing Rails plugins from Github on Windows
Posted 3020 days ago

Well, I have installed several Rails plugins but I was bummed when I tried to install the re-captcha plugin from Github. The command belwo just fails silently and creates an…

How to install RMagick + ImageMagick on Windows
Posted 2783 days ago

I have installed RMagick and Image Magick on many Windows machines and I have stumbled across various kinds of errors, and finally I have decided to document them so that…

Installing gems behind proxy servers
Posted 3441 days ago

It is well documented as part of gem help that using the following common options:

-p, --[no-]http-proxy [URL]      Use HTTP proxy for remote operations

will allow gem to use the proxy server…

ruby-alibris wrapper wins
Posted 2235 days ago

I had blogged about my recent open-source project, a Ruby wrapper for the Alibris API, ruby-alibris. Soon after, Alibris had announced their First Annual Alibris API Programming Contest, and I submitted…

Playing with CoffeeScript
Posted 2403 days ago

After having used Haml and Sass and loving them, a friend introduced me to CoffeeScript. In short CoffeeScript is to Javascript as Haml is to Html and Sass is to…

Playing with CoffeeScript
Error in Ruby relative_path_from call on Windows
Posted 2640 days ago

I was recently working on some code for building an extension for Spree, when I ran into an issue while generating a extension controller. The error only happens on Windows.

The…

Rails Magazine releases free Issue #5 digital edition
Posted 2790 days ago

Themed in beautiful Winter art and pictures, Rails Magazine released their Issue #5 free digital edition to the whole Ruby and Rails community worldwide.

It is the largest issue since we…

Rails Magazine releases free Issue #5 digital edition
Tip: has_one and nested form/attributes
Posted 2925 days ago

Although, the usage of nested forms with has_many associations is well documented, I found that especially the call ..build that works for has_many associations do not work for has_one associations.…

Install SQLite3 on Windows
Posted 3003 days ago

I found this great screencast that shows how easily you can install SQLite3 on Windows. So, here you go:

Install SQLite3 on Windows

PreviousNext

Jun 29 / Rupak Ganguly

Rails Magazine Issue #6 released

Rails Magazine Issue #6

Rails Magazine Issue #6

I am very happy to announce the release of the Rails Magazine Issue #6. It took us a while to get this issue out but it is better late than never. We improved a lot on the backend side and revamped into a new automated publishing system. This will in future enable us to streamline the author submission, editing and publishing process. Olimpiu and Raluca Metiu, the husband/wife combo, worked very hard to get the new publishing system up.

In this beautiful 36-pages full color issue you will find some very in-depth articles and a couple of nice interviews. The issue consists of the following:

  • Beautifying Your Markup With Haml and Sass by Ethan Gunderson
  • Scaling Rails by Gonçalo Silva
  • Interview with Sarah Allen by Rupak Ganguly
  • Data Extraction with Hpricot by Jonas Alves
  • Deployment with Capistrano by Omar Meeky
  • Fake Data – The Secret of Great Testing by Robert Hall
  • RubyConf India 2010 coverage by Judy Das
  • Previous and Next Buttons by James Schorr
  • RVM – The Ruby Version Manager by Markus Dreier
  • Interview with Michael Day of Prince XML by Olimpiu Metiu

The digital edition (PDF) is available for free at http://www.railsmagazine.com/issues/6. You can also grab a printed copy  available in US, UK and Canada (8.80 USD + shipping).

Download the free digital edition of Rails Magazine Issue #6.


Jun 7 / Rupak Ganguly

The new iPhone 4 phone is here…

Steve Jobs announced the arrival of iPhone 4 at WWDC today. The highlights of the iPhone 4 are as below:

1. New Hardware Design: Front and back camera with flash, 2 mics, integrated antennae, and 24% thinner. Quad band HSDPA, 7.2Mbps, 802.11n WiFi, GPS, compass, accelerometer.

2. Retina Display: Four times as many pixels, 326 pixels per inch (300 is the limit for the retina!), 3.5 inch display, 960 x 640 pixels, 326 pixels per inch, 800:1 contrast ratio, IPS technology (better than OLED)

3. iPhone 4 is powered by the A4 chip: Micro-SIM, larger battery – improved battery life – 7 hours of 3G talk, 6 hours of 3G browsing, 10 hours of WiFi browsing, 10 hours of video, 40 hours of music and 300 hours of standby.

4. Gyroscope: 3 axis gyro, the gyro tied to accelerometer, compass together for six axis. pitch, roll, yaw. rotation about gravity, 6-axis motion sensing.

5. New Camera system: 5 megapixel, backside illuminated sensor. 5x digital zoom, tap to focus, and an LED flash. Records HD video – 720p at 30 fps. LED flash stays for video recording. You can record, edit and email right from the iPhone. iMovie for iPhone at $4.99.

6. iOS 4: iPhone OS4 aptly renamed to iOS4. You can see the features in another post I wrote earlier.

7. iBooks: Bookshelf, PDF reader, iBookstore

8. iAds: Apple’s ad network, comes on live on July 1st, 2010 for all iOS 4 devices.

9. FaceTime: Video calls on iPhone. WiFi only. iPhone 4 to iPhone 4. No setup. Camera can be flipped to the rear or front. Portrait or Landscape. This has to be the all time, life-altering, feature in any product…

Checkout all the features, the design, and the full technical specs of the new iPhone 4 phone at Apple. Last but not the least, see it for yourself in this video of the new iPhone 4 phone and the photo gallery in all its glory…


Availability: Pre-order starts on June 24th, 2010. “AT&T is going to make an incredibly generous upgrade offer. If your contract expires at any time in 2010, you can upgrade to the iPhone 4. You can get it up to six months early.”

Colors: White and black.

Pricing: iPhone 4 – $199 for 16GB, $299 for 32GB. iPhone 3GS – $99.

iOS 4 upgrades: For the 3G, not all the features are supported, same with the iPod touch, and this excludes the first generation. Upgrades are free for all these products. Available on June 21st, 2010.

Hat tip: Engadget and gdgt did a live coverage of the event. Thank guys, for your coverage for people like us, who could not attend in person.


May 28 / Rupak Ganguly

Error in Spree rake db:bootstrap issue – stack level too deep

I have been working on some Spree based ecommerce stores lately, and I ran into this issue while creating a new Spree project. I had bumped into this a while back but did not write about it then. But, now I have decided to pen it down.

The steps to creating a new Spree project is very simple. Assuming that you have Ruby and Rails both installed, you can simply do:

$ gem install spree

$ spree mystore

$ cd mystore

$ rake db:bootstrap

$ script/server

And, voila you should have a shiny Spree store.

But, I have bumped into an issue at the step $ rake db:bootstrap as shown below:

$ rake db:bootstrap
(in c:/RoRProjs/wixspree)
rake aborted!
stack level too deep
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2390:in `raw_load_rakefile'
(See full trace by running task with --trace)

After a little digging, I found out that Spree has a dependency on the ‘jeweler’ gem which in turn has some kind of dependency on Git.

So, although it seems like a weird solution but just by initializing a git repository on your Spree project folder i.e. mystore in my example, you will be happy to see that the problem is resolved.

So, to recap, in the above steps to create your new Spree project, add a new step before the rake step:

$ git init

$ rake db:bootstrap

You should be golden by now. Hope it helps.

Note: I am running Spree 0.9.4 on Windows Vista and Rails 2.3.5 and Ruby 1.8.6 (ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32])

Note: If you do not have Git installed, you might want to do that. Here are some excellent articles which show how to do it:

http://github.com/guides/using-git-and-github-for-the-windows-for-newbies

http://kylecordes.com/2008/git-windows-go

http://www.gitcasts.com/posts/git-on-windows


May 27 / Rupak Ganguly

Error in Ruby relative_path_from call on Windows

I was recently working on some code for building an extension for Spree, when I ran into an issue while generating a extension controller. The error only happens on Windows.

The error in the console looks like this:

$ ruby script/generate extension_controller PromotionManager admin/promotions
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#
version_requirements is deprecated and will be removed on or after August 2010. Use #requirement
Loading haml-edge gem.
c:/ruby/lib/ruby/1.8/pathname.rb:709:in `relative_path_from': different prefix: "c:/" and "C:/RoRPro
js/spreestore" (ArgumentError)
from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails_generator/lookup.rb:110:in `use_co
mponent_sources!'
from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails_generator/lookup.rb:109:in `each'
from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails_generator/lookup.rb:109:in `use_co
mponent_sources!'
from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails_generator/lookup.rb:55:in `include
d'
from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails_generator.rb:38:in `include'
from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails_generator.rb:38:in `send'
from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails_generator.rb:38
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:1
56:in `require'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:5
21:in `new_constants_in'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:1
56:in `require'
from script/generate:4

The error is specifically in this line:

c:/ruby/lib/ruby/1.8/pathname.rb:709:in `relative_path_from': different prefix: "c:/" and "C:/RoRPro
js/spreestore" (ArgumentError)

After a little digging, it was evident that the ‘relative_path_from’ method in ‘/ruby/lib/ruby/1.8/pathname.rb’ file had the problem. The problem was also described as a ticket at http://redmine.ruby-lang.org/issues/show/1366 and the excerpt of the issue is shown below:

On Windows, the case of the drive letter can be either upper case or lower case (eg, "C:" or "c:") on the same machine at the same time in different Command Prompt Windows (see below for details). Dir.pwd will return either lower-case or upper-case for the drive letter (“C:/” or “c:/”) depending on the Command Prompt it is run from. However, FILE always uses lower-case drive letter. This can cause an ArgumentError when comparing Dir.pwd and FILE using Pathname#relative_path_from. This happens with version 1.9.1p0 as well. Pathname#relative_path_from should deal with the case where the case of the argument is different.

Note, that I have both my ruby install folder and my project folder on c: drive. And, I am running Ruby 1.8.6  - ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]

Solution

I monkey-patched the following lines in pathname.rb file as shown below.

def relative_path_from(base_directory)
dest_directory = self.cleanpath.to_s.capitalize!
base_directory = base_directory.cleanpath.to_s.capitalize!

I added the capitalize! keyword at the end of the two lines so that both the paths are in uppercase, so that later in the code (line 708-710) shown below does not barf and give us the error we got shown in the first para. of the article.

if dest_prefix != base_prefix
raise ArgumentError, "different prefix: #{dest_prefix.inspect} and #{base_directory.inspect}"
end

The temporary solution works after the patch. Hope it helps.


Mar 23 / Rupak Ganguly

Smashing Magazine needs help! Let’s give back…

Smashing Mag. eBook For over the years I have read and enjoyed the articles and posts from Smashing Magazine. They have helped me in contrasting and getting to the bottom of a lot of things. I have benefited from the excellent viewpoints, free fonts, free themes that they made available from time to time. As always, as I was reading the daily post, and I read the following and I wanted to help as well.

What happened here today, on the Smashing Magazine’s website? Well, here is the thing: we need your help. Only sound financial conditions can guarantee the steady stream of high quality content which you are used to on Smashing Magazine. Today we need your financial support. Please help us by buying our new eBook "Professional Web Design".

Well, needless to say I went ahead and ordered the eBook. In the past, I have ordered their printed book “The Smashing Magazine Book”. The printed book is a valuable asset to novice and experienced web developers and designers alike. I am looking forward to reading the eBook. The eBook contains a selection of their best articles about professional Web design and the business side of web development. It contains 10 already published articles and 2 exclusive, newly written pieces. The book costs only $9.90.

Plea: Please tweet my post, or just tweet the url to the eBook and the printed book so that we can all help Smashing Magazine. It is a very small thing on our part to do to keep this very valuable asset going.

Technorati Tags:

Jan 4 / Rupak Ganguly

How to install RMagick + ImageMagick on Windows

I have installed RMagick and Image Magick on many Windows machines and I have stumbled across various kinds of errors, and finally I have decided to document them so that I could not only document it for myself, but for other people like me, who are stuck due to these errors.

Update: I have also included instructions for installing RMagick on Ubuntu and MacOSx as well.

Installation on Windows

The issues that I have faced are as follows:

A. This version of RMagick was created to run with ImageMagick 6.3.0 but ImageMagick 6.3.5 is installed on this system. You should either
1) Configure and build RMagick for ImageMagick 6.3.5, or
2) download ImageMagick 6.3.0 from http://www.imagemagick.org and install it.
B. Errors about missing CORE_.. .dll file(s).
C. Errors about missing sqlite3.dll.

Issue A. stems from the fact that you have a incompatible version of ImageMagick installed which does not work with RMagick. The solution would be to uninstall any existing ImageMagick and/or RMagick gem, and start all over as described below.

Issue B. tells me that either ImageMagick or RMagick is not installed properly.

Issue C. is a bit off and has nothing to do with ImageMagick or RMagick. It is probably being thrown by the plugin or application that you are using that needs ImageMagick or RMagick. To fix this issue, just install Sqlite3 and I have a post just for that.

Now that we have tackled the issues, let’s get to the goal – how to install RMagick + ImageMagick on Windows.

  1. Uninstall any Image Magick or RMagick gem from before.
  2. Download rmagick-win32 for windows that has the gem and the ImageMagick installer from http://rubyforge.org/frs/download.php/64917/RMagick-2.12.0-ImageMagick-6.5.6-8-Q8.zip
  3. Unzip the rmagick-win32 zip file that you downloaded above.
  4. Install the ImageMagick from the installer that came in the zip i.e. run the ImageMagick-6.5.6-8-Q8-windows-dll.exe. This will install ImageMagick for you.
  5. Now, we need to install the rmagic gem that came in the zip i.e. rmagick-2.12.0-x86-mswin32.gem. To do that, run the following command on a windows command line:
    > gem install <path where you downloaded and then unzipped the rmagick zip>\rmagick-2.12.0-x86-mswin32.gem

    Note: When you read this post, the version nos. of the gem and the zip file may change. Please adjust your commands for that.

  6. If you get Issue C., from above you probably are left with installing Sqlite3. If you need help you can look up my post.

That should get you going on Windows machines. Yet another big Ruby on Rails development hurdle on Windows, solved for good.

Installation instructions for Ubuntu

1. Undo any old leftover install baggage

sudo apt-get remove --purge librmagick-ruby-doc librmagick-ruby1.8

2. Install the appropriate version

sudo apt-get install libmagick9-dev ruby1.8-dev

3. Install the rmagick gem

gem install rmagick

That should get you going on Ubuntu machines.

Installation instructions for MacOSx

If you want to use Homebrew, then do the following:

1. Install ImageMagick via a homebrew

brew install imagemagick

3. Install the rmagick gem

gem install rmagick

If you want to use macports, you can see the instructions at the RMagick site.

That should get you going on MacOSx machines.

If you have any other issues or questions regarding the subject, please let me know via comments. I will try my best to help you.


Dec 28 / Rupak Ganguly

Rails Magazine releases free Issue #5 digital edition

railsmagazine-cover5 Themed in beautiful Winter art and pictures, Rails Magazine released their Issue #5 free digital edition to the whole Ruby and Rails community worldwide.

It is the largest issue since we started, with a whopping 65 pages in full-color, of excellent articles from various authors covering various topics.

It is a Holiday gift from Rails Magazine to all of the Ruby and Rails enthusiasts. You can download the print edition from here.

This issue covers various topics and builds upon earlier articles in the series. The following is a synopsis of the material available in this issue:

  • Authentication with Gigya by Curtis Jennings Schofield
  • Background Processing in Rails by Erik Andrejko
  • On Your Rails (and Ruby) Education by Bob Martens
  • Sinatra: Fast Web Application in Ruby by Carlo Pecchia
  • Sprockets by Starr Horne
  • Adding Pre-made Extensions to Radiant CMS by Casper Fabricius
  • Protecting Your Application From Impostors by Gavin Morrice
  • Geography division select tag by Satish Kota
  • RailsBridge: Rebooting the Rails Community by Mike Gunderloy
  • Prince: Powerful PDF Generation by Michael Bleigh
  • Ruby C Extension Development by Claudio Fiorini
  • Using the Twitter API with Ruby by Brian Rivard
  • Continuous Integration Tools in Rails by Saurabh Bhatia
  • Active Scaffold by Payal Gupta
  • Implement a Full Text Search Engine with Xapian by Amit Mathur

Keeping up with the spirit, we are trying to get the schedule for the magazine a bit more predictable. We are hoping we can get out 6 issues or even 12 issues for the coming year. Time will tell. But, whatever the schedule is or however many issues we can release, we will surely make sure we get quality content over to our readers.

We welcome new authors to write for us. Please contact me (rupak /dot/ ganguly /at/ railsmagazine /dot/ com) or Olimpiu Metiu (editor /at/  railsmagazine /dot/ com for details. You can also visit the official website for Rails Magazine.

If you have any feedback, please do write to us or participate in the survey to tells us what you want to read.


Nov 26 / Rupak Ganguly

Happy Thanksgiving – This year I am thankful for…

It is the festive time of the year. With leaves turning colors and trees going bald thereafter, the season ushers the festivities – Diwali, Durga Puja, Halloween, Thanksgiving and finally Christmas.

Well, it is Thanksgiving and it is customary to thank people who touched your lives. On the personal front, I am thankful to my wife for being a great companion and for being the love of my life. I am thankful to my beautiful kids to be part of my life. I am thankful to my dad, mom and sister for their blessings and love. I am thankful to all my friends for being there for me, supporting me and being part of my life. Above all, I thank God for everything he has bestowed upon me and my family.

On the professional front, it has been a great year for me. It was the year I planned to step up my freelancing efforts. I was blessed and I nailed a few projects. During the course of the year, while I dabbled in code, I am thankful to a lot of people.

I am thankful for the great plugins by Rick Olson (technoweenie) and John Nunemaker, that I used in my projects. I am thankful to the team behind Aptana for providing an excellent Ruby on Rails IDE for free. I am thankful to Ryan Bates for his invaluable screencasts at Railscasts.com which has helped in numerous occasions. I am thankful to Unfuddle and Github for hosting the source code for my projects for free. I am thankful to the numerous bloggers who’s postings have inspired me and helped me learn along the way.

I am thankful to Olimpiu Metio at Rails Magazine to make me part of the editorial team. I am thankful to the great team members Bob Martens, John Yerhot, Khaled al Habache, Mark Coates, Starr Horne and Carlo Pecchia at Rails Magazine. We had a blast. By the way, Issue #5 coming soon in Dec. I am thankful to all the authors for their cooperation and all the people I interviewed for their time.

I am thankful to RailsBridge Builders for giving me an opportunity to work on open source projects and helping non-profit organizations. I would like to thank Mike Gunderloy for his leadership and vision for RailsBridge. I would like thank Mike Breen for his help and support in various projects.

I am thankful to Sarah Allen, Grace Liu, Chris Lerum, Thomas Jack and Petros Amiridis for an excellent team experience while working on Sunset PTA project. I learned a lot in team work and gained insight in working with people in different time zones.

I want to also thank my good friend Wynn Netherland for keeping my hopes high, giving me advice, showing me the path and encouraging me. Thanks a lot for inspiring me with your work.

Finally, last but not the least, I want to thank all that have subscribed to this blog and my other blog, followed my tweets and encouraged me with their comments and feedback. Please keep them coming.

I wish you all a very Happy Thanksgiving!


Aug 31 / Rupak Ganguly

Rails Magazine releases Issue #4 in print edition

railsmagazine-cover4 Dubbed as “Future of Rails”, Rails Magazine released Issue #4 in print. You can download the print edition from here. This issue brings 32-pages, filled with exclusive RubyKaigi 2009 conference coverage, in-depth articles, interviews with David Heinemeier Hansson, Matz, Yehuda Katz, Tom Enebo and Koichi Sasada.

The RubyKaigi 2009 coverage provides a nice roundup about the conference with articles, photos and session information. The interviews are great giving insights into Rails 3, Ruby 1.9 and JRuby. And, last but not the least, this issue also brings a wealth of knowledge via the fine articles on various topics.

I thoroughly enjoyed interviewing Yehuda Katz and Tom Enebo and I thank them both for their participation.

If you have any feedback, please do write to us or participate in the survey to tells us what you want to read.

Please be on the lookout for the free downloadable digital version which will be released soon!

Table of Contents:

A Word From the Editor by Olimpiu Metiu

Background Processing with Delayed_Job by James Harrison

Generating PDF with ODF templates by Rodrigo Rosenfeld Rosas

Interview with Yehuda Katz by Yehuda Katz and Rupak Ganguly

Interview with David Heinemeier Hansson by Mark Coates

Feel the Radiance with Radiant CMS by Saurabh Bhatia

Interview with Thomas Enebo by Thomas Enebo and Rupak Ganguly

Oracle Tips and Tricks by Greg Donald

Ruby Kaigi Rails Magazine Exclusive Coverage by Khaled al Habache

RubyKaigi 2009 Roundup by Ehab El-Badry

Interview with Matz by Yukihiro Matsumoto and Muhammad Ali

Interview with Koichi Sasada by Koichi Sasada and Muhammad Ali


Aug 15 / Rupak Ganguly

Tip: has_one and nested form/attributes

Although, the usage of nested forms with has_many associations is well documented, I found that especially the call ..build that works for has_many associations do not work for has_one associations. For the code to work for has_one associations, use this instead:
.build_
E.g book.build_author where book has_one association to author.

Hope this helps.