Follow us:

Saturday, January 14, 2012

Up and running with ruby 1.9.3 for rails 4 versions

Rails/master is now 4.0.0.beta and will support only ruby 1.9.3+ as per Riding Rails.
For installing multiple versions of ruby, basically we will go with

As both have its own pros and cons, instead of comparing lets try to work on how to install the ruby versions in both ways.

Rbenv


Steps to install rbenv:
$ cd ~
$ git clone git://github.com/sstephenson/rbenv.git .rbenv

Now the latest version of rbenv will be located in our home directory.Add the following lines of code in ~/.bashrc
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

Restart your shell so the path changes take effect. You can now begin using rbenv.
$ exec $SHELL

Install ruby versions into ~/.rbenv/versions .Now download the ruby 1.9.3 version from ruby-lang, before that create a directory inside ~/.rbenv/versions and place the ruby 1.9.3 source files

$ cd ~/.rbenv/versions
$ mkdir rubysrc
$ cd rubysrc
$ curl -O http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz

Configure the ruby source 1.9.3
$ ./configure --prefix=$HOME/.rbenv/versions/ruby-1.9.3-p0
$ make
$ make install

Now ruby 1.9.3 have been installed in the ~/.rbenv/versions/ruby-1.9.3-p0 folder.

Finally run this command after you install a new version of ruby.
$ rbenv rehash
rbenv rehash will rebuild the shim binaries

RVM


Lets try the ruby installation with RVM. If you have not installed RVM, then find the guides from Installation Guide.

First check the default ruby installed in the system
$ rvm list
rvm rubies
=> ruby-1.9.2-p0 [ i386 ]

For upgrading your older rvm, then try with RVM Upgrade

Now install ruby-1.9.3 in your rvm
$ rvm install 1.9.3-p0
Once the installation over, check the rubies installed in your system now
$ rvm list 
rvm rubies

   ruby-1.9.3-p0 [ i386 ]
=> ruby-1.9.2-p0 [ i386 ]

Guess the post will be useful, for suggestions please comment on this post.

Monday, October 10, 2011

Paperclip::CommandNotFoundError: Paperclip::CommandNotFoundError

If you find this error in your rails app project, then check whether rmagick is installed.If not please follow the steps from this article.

If you already installed rmagick, then check the log files.
[paperclip] An error was received while processing: #
[paperclip] /usr/local/bin/identify -format %wx%h '/tmp/stream20111010-11774-rdcjsn.gif[0]' 2>/dev/null
Paperclip uses Imagemagik for image manipulation. The error says it can't find indentify which is an imagemagik command.

In my case. i have added the line Paperclip.options[:command_path] = "/usr/bin" in development.rb.

Tuesday, October 4, 2011

Javascript integer alerts

While working on a javascript issue for our project, we notice the strange behavior of integers and strings.We were about to validate  the users Social Security Number and later we noticed if any customer types 001234567, it seems to be changed to a random number 342391.

Hardly its tough for us to save it in database.While debugging via firebug, we noticed during the client side validation , the numbers are changing. Lets try something like alert(000123456) in the javascript console, we will find a random number.

Then we came to conclusion, before passing the numbers for client side validation, we are converting it into string.So that random number won't get generated. So while dealing with the sensitive data like SSN number, please be aware to implement the number as strings instead integers.