Wednesday, October 07, 2009

Getting started with Ruby on Rails

Here is a very simple tutorial to get started : http://www.digitalmediaminute.com/article/1816/top-ruby-on-rails-tutorials. First 2 links on that page are a good start:

Rolling with Ruby on Rails : http://oreilly.com/pub/a/ruby/archive/rails.html?page=1

Rolling with Ruby on Rails, Part 2 : http://oreilly.com/ruby/archive/rails2.html

Points below are some issues I faced and how I resolved them. I installed Ruby with the one-click installer for Windows : http://rubyforge.org/frs/?group_id=167. This also installs gem which can be thought of as a package manager.

C:\Projects>gem install rails --remote
Install required dependency actionpack? [Yn]  Y
Install required dependency rack? [Yn]  Y
Install required dependency fcgi? [Yn]  Y
Building native extensions.  This could take a while...
ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
    ERROR: Failed to build gem native extension.

ruby extconf.rb install rails --remote
checking for fcgiapp.h... no
checking for fastcgi/fcgiapp.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --srcdir=.
        --curdir
        --ruby=c:/ruby/bin/ruby
        --with-fcgi-dir
        --without-fcgi-dir
        --with-fcgi-include
        --without-fcgi-include=${fcgi-dir}/include
        --with-fcgi-lib
        --without-fcgi-lib=${fcgi-dir}/lib

Gem files will remain installed in c:/ruby/lib/ruby/gems/1.8/gems/fcgi-0.8.7 for
inspection.
Results logged to c:/ruby/lib/ruby/gems/1.8/gems/fcgi-0.8.7/ext/fcgi/gem_make.out

The problem was that the one click installer for the Ruby on Windows installs version 0.9.4 of gems. An update via

gem update --system

brings it up to 1.3.4 which then allows successful install.

C:\Documents and Settings\VSanzgiri>gem update --system
Updating RubyGems...
Attempting remote update of rubygems-update
Install required dependency session? [Yn]  Y
Install required dependency hoe-seattlerb? [Yn]  Y
Install required dependency hoe? [Yn]  Y
Install required dependency rubyforge? [Yn]  Y
Install required dependency minitest? [Yn]  Y
Install required dependency hoe? [Yn]  Y
Successfully installed rubygems-update-1.3.5
Successfully installed session-2.4.0
Successfully installed hoe-seattlerb-1.2.1
Successfully installed hoe-2.3.3
Successfully installed rubyforge-2.0.0
Successfully installed minitest-1.4.2
Successfully installed hoe-2.3.3
Installing ri documentation for rubygems-update-1.3.5...
Installing ri documentation for hoe-seattlerb-1.2.1...
Installing ri documentation for hoe-2.3.3...
Installing ri documentation for rubyforge-2.0.0...
Installing ri documentation for minitest-1.4.2...
Installing ri documentation for hoe-2.3.3...
Installing RDoc documentation for rubygems-update-1.3.5...
Could not find main page README
Could not find main page README
Could not find main page README
Could not find main page README
Installing RDoc documentation for hoe-seattlerb-1.2.1...
Installing RDoc documentation for hoe-2.3.3...
Installing RDoc documentation for rubyforge-2.0.0...
Installing RDoc documentation for minitest-1.4.2...
Installing RDoc documentation for hoe-2.3.3...
Updating version of RubyGems to 1.3.5
Installing RubyGems 1.3.5
RubyGems 1.3.5 installed

n++=== 1.3.5 / 2009-07-21

Bug fixes:

* Fix use of prerelease gems.
* Gem.bin_path no longer escapes path with spaces. Bug #25935 and #26458.

Deprecation Notices:

* Bulk index update is no longer supported (the code currently remains, but not
  the tests)
* Gem::manage_gems was removed in 1.3.3.
* Time::today was removed in 1.3.3.

------------------------------------------------------------------------------

RubyGems installed the following executables:
        c:/ruby/bin/gem

RubyGems system software updated

 

Then you may install rails:-

C:\Documents and Settings\VSanzgiri>gem install rails --remote
Successfully installed rack-1.0.0
Successfully installed actionpack-2.3.4
Successfully installed actionmailer-2.3.4
Successfully installed activeresource-2.3.4
Successfully installed rails-2.3.4
5 gems installed
Installing ri documentation for rack-1.0.0...
Installing ri documentation for actionpack-2.3.4...
Installing ri documentation for actionmailer-2.3.4...
Installing ri documentation for activeresource-2.3.4...
Installing ri documentation for rails-2.3.4...
Installing RDoc documentation for rack-1.0.0...
Installing RDoc documentation for actionpack-2.3.4...
Installing RDoc documentation for actionmailer-2.3.4...
Installing RDoc documentation for activeresource-2.3.4...
Installing RDoc documentation for rails-2.3.4...

The tutorial assumes you have installed sqlite3 adapter. If not then you will have to modify /cookbook/config/database.yml to point to mysql installation.

No comments:

Post a Comment

Thank you for your feedback