Home

Rails 3 Setup with RVM

1 Comment

Rails 3.0 requires at least Ruby 1.8.7. Support for all of the previous Ruby versions has been dropped officially. Rails 3.0 is also compatible with Ruby 1.9.2.

What is rvm?
RVM is a command line tool which allows us to easily install, manage and work with multiple ruby environments from interpreters to sets of gems. More info about RVM

Install ruby 1.9.1 and Rails 3 using rvm in Ubuntu 9.10

To install rvm:

bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

I guess git is required for this. You can check whether git is installed using “git –version”, if not:

sudo apt-get install git
sudo apt-get install git-core

After Installation :
put the following line into your profile(/home/.profile) at the very bottom.

if [[ -s "$HOME/.rvm/scripts/rvm" ]]  ; then source "$HOME/.rvm/scripts/rvm" ; fi

Then load the new code into your current shell and start using RVM

 source ~/.rvm/scripts/rvm

Be sure to install any dependencies for your operating system.

rvm notes

Now add the sourcing line at the end of your profiles (~/.bashrc or ~/.bash_profile):

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

Then open a new shell and start using RVM!

 rvm install 1.9.1 

(This will install ruby in .rvm folder. see /home/<usr_name>/.rvm/src and bin)

 ruby -v
 #ruby 1.9.1p378 (2010-01-10 revision 26273) [i686-linux]
which ruby
 #/home/<user_name>/.rvm/rubies/ruby-1.9.1-p378/bin/ruby

To switch back to your system’s ruby :

 rvm system
ruby -v
 #ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-linux]

which ruby
#/usr/bin/ruby

Commands::
To setup rvm, ruby1.9.1 and Rails3 with current version of ruby & rails:

ruby -v

bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

OR
mkdir -p ~/.rvm/src/ && cd ~/.rvm/src && rm -rf ./rvm/ && git clone git://github.com/wayneeseguin/rvm.git && cd rvm && ./install

rvm install 1.9.1
rvm list
rvm 1.9.1
rvm 1.9.1 --default
rvm system
gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
gem install rails --pre
rails new blog
cd demo
gem install sqlite3-ruby
rails server
visit :: http://localhost:3000
rails generate scaffold post name:string
rake db:migrate

visit :: http://localhost:3000/posts

See list of ruby versions installed using RVM:

rvm list

#rvm rubies

=> ruby-1.9.1-p378 [ i386 ]

Add to: Facebook | Digg | Del.icio.us | Stumbleupon | Reddit | Blinklist | Twitter | Technorati | Yahoo Buzz | Newsvine

– Abhishek Singh

Ruby and Rails setup in Ubuntu 9.10(Karmic Koala)

2 Comments

1. Download ruby 1.9.1-p376 from Ruby site.
This is a patch level release of Ruby 1.9.1. Ruby 1.9.1-p243 has a security vulnerability that allows heap overflow.
Other fixes :

In addition, 1.9.1-p376 includes > 100 bug fixes.
  • Irb extension commands had been broken. It was fixed.
  • Ripper had not been able to parse some Ruby codes. It was fixed.
  • Fixed build failures on AIX.
  • Some bug fixes of Matrix.
  • Can load gems which is installed in an user’s home directory.
  • Some method became returning a string with a correct encoding.

Refer this for more updates.

Download ruby-1.9.1-p376.tar using this Direct download link.
2. Now make sure you have all the necessary dependencies installed.To check this type:

dpkg -l

3. This will show a list of installed packages. look for zlib1g and zlib1g-dev. If these packages are installed then OK, otherwise install these packages :
 sudo aptitude install zlib1g
 sudo aptotude install zlib1g-dev
4. Now create a src directory under /opt, ofcourse i could install in /usr/local. But installing in /opt will be benificial if in future i want to install another version (suppose ruby 1.8) side by side, in this case only changes in some symbolic links will be enough. So i created a src directory and changed group and premissions.
 sudo mkdir -p /opt/src
 sudo chgrp -R 'username' /opt/src
 sudo chmod 775 /opt/src
5. Move to /opt/src :
 cd /opt/src
6. Now copy the downloaded ruby 1.9.1-p376.tar.gz here and untar this:
tar xzvf ruby 1.9.1-p376.tar.gz
7. Go inside ruby 1.9.1-p376
cd ruby 1.9.1-p376
8. Now configure with options to make sure that things go in the correct directory, and with the correct suffix after the program name so that i can allow for different versions of Ruby if i want, in future.
 ./configure --prefix=/opt/ruby1.9 --program-suffix=1.9
9.  make and install:
 sudo make
 sudo make install
10. Finally create some symbolic links so that all terminals can look the installed ruby:
 sudo ln -sf /opt/ruby1.9/bin/ruby1.9 /usr/local/bin/ruby
 sudo ln -sf /opt/ruby1.9/bin/erb1.9 /usr/local/bin/erb
 sudo ln -sf /opt/ruby1.9/bin/irb1.9 /usr/local/bin/irb
 sudo ln -sf /opt/ruby1.9/bin/rdoc1.9 /usr/local/bin/rdoc
 sudo ln -sf /opt/ruby1.9/bin/ri1.9 /usr/local/bin/ri
 sudo ln -sf /opt/ruby1.9/bin/testrb1.9 /usr/local/bin/testrb
 sudo ln -sf /opt/ruby1.9/bin/gem1.9 /usr/local/bin/gem
11. Now check
ruby location
 which ruby
output should be:  /usr/local/bin/ruby.
Ruby Version:
 ruby -v
output should be:  ruby 1.9.1p376 (2009-12-07 revision 26041) [i686-linux]

12. Now to update gems:
 sudo gem update --system
Now if i do :
 gem list
output is:
*** LOCAL GEMS ***

13. Next step is to install rails:
 sudo gem install rails --include-dependencies
14. Again i will create the symbolic links for rails, rackup and rake, so that Ruby and it’s supporting apps point to the correct location:
 sudo ln -sf /opt/ruby1.9/bin/rackup /usr/local/bin/rackup
 sudo ln -sf /opt/ruby1.9/bin/rails /usr/local/bin/rails
 sudo ln -sf /opt/ruby1.9/bin/rake /usr/local/bin/rake
All’s done now.
New Rails application can be created by using:
 rails TestApp


Share This Post:

Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine

Abhishek Singh


I'm supporting RubyConf India 2010

Useful Paperclip Tutorials

Leave a comment

Here are some useful Tutorial for paperclip plugin in rails

1. For newly installed Paperclip in ruby 1.9.1, giving “Internal Error” and “invalid byte sequence in US-ASCII” with rack/utils.rb problem. Follow This

2. Paperclip Sample application. Here

3. Paperclip Sample application : Downloading files through controller. Here

4. Paperclip Sample Application : Storing attached file in database BLOB column. Here and one More

5. Paperclip upload file using single database table. Here

6. Paperclip Sample application download. Here

7. Good tutorial on attaching a file using Paperclip.

8. Uploading multiple images using Paperclip. Here

9. RoR Paperclip plugin tutorial. Here

Share this post using following toolbar:

Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine

– Abhishek Singh

I'm supporting RubyConf India 2010