3 Step Solution to Missing rs-ruby error

Today we were trying to move one project of rails from one pc to the other. We took the source code along with the db (since the db had data in it and it was required) and configured it. But when we started the server using ruby script/server we got a strange error missing rsruby

searched for it and tried few things. Finally got it solved in 3 steps

>export R_HOME=/usr/lib/R
> sudo ln -s /usr/lib/R/lib/libR.so /usr/lib/libR.so
> gem install rsruby — –with-R-dir=$R_HOME –with-R-include=/usr/share/R/include/

Thats all… rsruby will be installed on your system and the project will be running without any issue.

Hope this works for you


Be Sociable, Share!

Handling cookie overflow problem in rails

Are you getting cookie overflow error when you are loading a lot of flash[:notices] ??

Something like CGI::Session::CookieStore::CookieOverflow

if so here is a solution for it

Just write this method in ur controller

before_filter :session_cleanup

def session_cleanup
backup = session.data.clone
backup.each { |k, v| session[k] = v unless k.is_a?(String) && k
=~ /^as:/ }

What this will do is it will clear old data thats already there in the session and restore this one.

The above method wont work if your data size is >= 4k in that case the only solution is to use another session store.

Hope this helps 🙂 … Njoi

Be Sociable, Share!

Read XML file using Hpricot in Rails

Here is a small post on how to read an xml file using Hpricot in your Rails application.

First of all you need to install hpricot with the following command

gem install hpricot

Here is a sample xml file which I want to read. You can just paste the following code and create .xml  file


<name> test </name>


<name> test 123</name>


Now here comes the code to read this file. Don’t forget to add require ‘hpricot’ in the controller where you are putting this code.

test = Hpricot::XML(File.open(“test.xml”, “r”))

(test/:profile).each do |pro| render :text=>(((pro.at(“name”).innerHTML.strip).to_s)+”=>”+(pro.at(“   _id”).innerHTML.strip).to_s).inspect and return false

Remove .inspect and return false once u get the required output

Hope this helps. If you have any doubts just post a message and I will try to reply.

Be Sociable, Share!

Setting up FTP or SFTP server using vsftpd on ubuntu

Recently I was given a task to configure FTP server so that the user can upload files through FTP. I found VSFTPD really a good solution for it. Its very simple to configure Here are the steps

1) Install vsftpd using the following command

sudo apt-get install vsftpd
2) On doing so it will get installed in /etc path by default. To confirm the same go to /etc/vsftpd.conf using

sudo nano /etc/vsftpd.conf

Now if you want to allow local users to login find local_enable=YES  and uncomment it

To disable anonymous ftp change anonymous_enable=YES to anonymous_enable=NO

Uncommenting the line (write_enable=YES) will let ftp users upload content to the server. (Thats what I wanted to do)

Thats all its done. Restart the server using

sudo /etc/init.d/vsftpd restart

This is how you will be able to allow ftp login.

But if u have many sites hosted on a server and you want to allow to access only one particular site to a certain user you need to do the following

1) create groups for specific sites using

groupadd site1
chgrp -R site1 /var/www/site1

2) Add user to that group

useradd -G site1 username

3) Give permission to a particular group

chmod -R  g+w /var/www/site1/*

I think thats all. You should be able to access your server using ftp and even upload content on it.

Oh yes one more thing was I wanted the user to go directly to the folder where i wanted him to upload the file. So for that you need to change the root path/home path. For this u need to open passwd file in /etc using

nano /etc/passwd

Looks for the ftp access and the username You will find the current path. In most cases it will be /home change that to your preferred one.

Hmm Thats it..

Be Sociable, Share!

Deploy or Configure Rails on a Ubuntu Server

I have configured many servers till now on different OS. Like CentOs, Fedora and Ubuntu. From all the Operating systems Ubuntu is my favorite. The reason is its rails friendly according to me. Also Fedora is also good but I like Ubuntu more might be just bcoz I am more used to it 🙂

Talking about configuring rails app on an Ubuntu server takes following steps on a plain slice

1) Step 1 will be to install basic ruby gems and other packages

If its a blank slice you might also need to update ur repos using

apt-get update and aptitude install build-essential before u start installing ruby and other required libraries

sudo aptitude install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby sqlite3 libsqlite3-ruby1.8.

2) Create simlinks

sudo ln -s /usr/bin/ruby1.8 /usr/bin/ruby
sudo ln -s /usr/bin/ri1.8 /usr/bin/ri
sudo ln -s /usr/bin/rdoc1.8 /usr/bin/rdoc
sudo ln -s /usr/bin/irb1.8 /usr/bin/irb

3) Install Ruby gems (Make sure you have the latest version from http://rubyforge.org/frs/?group_id=126

We will use the 1.3.2 version. Get the tar version from http://rubyforge.org/frs/download.php/55066/rubygems-1.3.2.tgz using wget http://rubyforge.org/frs/download.php/55066/rubygems-1.3.2.tgz.

Then do  tar xzvf rubygems-1.3.2.tgz

cd  rubygems-1.3.2

sudo ruby setup.rb (to install the setup)

then do simlink sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

4) Then install rails (most important :D)

gem install rails -v 2.2.2 (make sure u specify the version u want to install else it will install the latest one)

5) Next step will be database. I use MySql and so here is the procedure  for it

sudo aptitude install mysql-server mysql-client libmysqlclient15-dev

You will be prompted to enter password 2-3 times while the installation is on. Don’t forget to setup a password.

6) Then comes one important part which is mysql-ruby library. Most people forget this and then MySql don’t work for them.

sudo aptitude install libmysql-ruby1.8

I think that’s all for Ruby + Rails + Ruby gems + Mysql

7) Since you are using Ubuntu make sure u have installed all the essentials things using

aptitude install build-essential.

This will install cc, gcc and other core required libraries. which will help u in installing gems and configuring them. (if you haven’t done that before)

8 ) Like I said before you will now also require gem. And the most common one is ImageMagick and Rmagick you can install them using

sudo apt-get install imagemagick

sudo apt-get install libmagick9-dev

sudo gem install rmagick

These 3 steps works in most cases. If it doesn’t work for you let me know via comment and I shall help u in solving it. You may also visit my previously written blog post on http://blog.dhavalparikh.co.in/2008/02/rmagick-installation-on-ubuntu/

9) Some other important ones are capistrano and git which u might require to install. Not covering them as of now.

10) You might also require nginx for webserver (I use Nginx so I am writing about it).

sudo aptitude install nginx

This will install nginx. For more information about nginx and its configuration you may visit my previous posts on


That’s more than what you need to run a basic rails apps. But I think these are essentials for a good rails app deployment.

You can even read more about Mongrel Clustering with Nginx on my posts which could be again a part of server configuration


I think thats all. If you have any doubts or problems write me a comment and I shall reply u ASAP.

Be Sociable, Share!

My Gmail hangs up and is very slow what should I do?

Well if that’s the problem you are facing then its not ur fault or nothing is wrong with your pc. Something is wrong with Gmail. Especially when you are using Firefox 3.5 you are sure to face this issue unless ur lucky.

Last month when i upgraded my browser to FF 3.5 I started facing the issue and realized that the issue was with Firefox and not Gmail since it was working properly in safari and other browsers. So as usual I googled and found this http://groups.google.com/group/mozilla.support.firefox/browse_thread/thread/805c8e689b64b8d2/adf482dcb49bb423

So I came to know that I am not the only one facing the issue. Then I tried couple of suggestions given in the thread and finally I have the list and solution for solving this problem. Here are the steps which you need to follow to get things working properly.

1) Clear history, cache every thing using the Clear history option in your browser

2) Next step is open GMail go to settings and check the last option Browser connection: Select Don’t always use https. Using Https will make things secure but slow. so let Gmail manage it on its own.

3) Look if you are using Firebug (A Mozilla Addon especially used by web developers) . If you are using that Disable it dont keep it running all the time.

4) Now finally the labs section. Gmail has many new features in the lab section. Try to disable the ones you don’t need.

5) Remove all unwanted add-ons

I think thats all restart Firefox and things should be alrite. If you are still facing issues Post me a comment and I shall help you out.

Be Sociable, Share!
1 3 4 5 6 7 27