Problems Faced while setting up Rails 3 with Ruby 1.9.2

I migrated all my applications to Rails 3 with ruby 1.9.2, after I installed ruby I faced few errors.

Few of them are

1) The arrow keys were not working in irb console and “no such file to load –readline” error.

This is the problem which occurs when the readline extension is not installed with ruby source. All you have to do to fix this error is

Go to your ruby source folder you downloaded and installed ruby from.

1.  cd  ~/ruby-1.9.2 2.  cd  ext/readline

And execute the commands below.

3. ruby  extconf.rb 4. make 5. sudo make install

If you find any errors while executing ruby extconf.rb showing ..no for each checkings. Then you need to install these two libraries on your system

sudo apt-get install libncurses5-dev libreadline5-dev

then later execute the commands starting from 3.

2) The other error was after I create application and start the server, the error was “no such file to load –openssl”

Again it was the error with openssl ruby extension not installed with ruby, you can fix this error by executing the following commands.

Go to the ruby source file

1. cd  ~/ruby-1.9.2 2. cd  ext/openssl

and execute the commands below.

3. ruby extconf.rb 4. make 5. sudo make install

If you find any errors while executing the command ruby extconf.rb showing ..no for each checkings, then you need to install the package in your system

sudo apt-get install openssl libopenssl-ruby libssl-dev

Then later execute the commands starting from 3.

Similarly I found many other files which were causing errors since the extensions were not installed like zlib etc.

If you find ‘no such file to load error ‘ for any of the extensions, then you need to go to ruby source folder. Go to respective directory inside ext/ (eg: readline/ for ‘no such file to load –readline’) and execute the following commands inside that folder

ruby extconf.rb make sudo make install

If you cannot successfully execute ruby extconf.rb, then you need to install respective libraries and execute these commands above again.

Note: I work on ubuntu operating system, If you face same errors in centos or any servers which I faced on a server with CentOS where you don’t have apt-get or aptitude installer, you need to search for particular package with yum search and install the package compatible with your operating system. Hope this helps.

——————————————

Install Rails3 on Ubuntu system with Rails 2.X.X in the system.

I was working on Rails 2.x.x and all I did to catch Rails3 was removed the old Ruby library, uninstalled Rails and gems and installed a latest Ruby library which supports a newer version Ruby on Rails i.e Rails3. The commands I executed to remove the Ruby library were

# sudo gem uninstall rails

This will uninstall the Rails in your Ubuntu system

# sudo apt-get purge ruby rubygems

This will purge the Ruby library and all gems installed in your system.

After uninstalling I installed Ruby-1.9.2 by following commands

# wget ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p0.tar.gz

# tar -xvvf ruby-1.9.2-p0.tar.gz

# cd ruby-1.9.2

# ./configure

# make

# sudo make install

It was just installation of this Ruby library, it got me the irb and gem installed in my system since all Ruby libraries with 1.9.X versions has irb and gem inbuilt unlike old Ruby versions where we had to install irb and gem manually.

I installed Rails3 with following command

# sudo gem install rails –version 3.0.0 # sudo bundle install      // This installs all the supportive bundles required.

This got me Rails3 installed in my system, and creation of project and running the application server is little different compared to Rails 2.x.x .

Creating sample application using Rails3 with scaffolding

->     rails new application_name -d mysql ->     rails generate scaffold Post title:string body:text ->     rake db:create   ->     rake db:migrate ->     rails server

I got the welcome page of Rails3 app.

Get in touch with us.

Subscribe For Latest Updates

Related Posts

Leave a Comment

Your email address will not be published. Required fields are marked *

en_USEnglish