Rails validate phone and email

validates_format_of :phone, with: /\A(\d{10}|\(?\d{3}\)?[-. ]\d{3}[-.]\d{4})\z/
validates_format_of :email, with: /\A[\w]([^@\s,;]+)@(([\w-]+\.)+(com|edu|org|net|gov|mil|biz|info))\z/i

wow!!!! thats complicated

validates_format_of :email, :with => /@/

thansk to this blogger : http://davidcel.is/blog/2012/09/06/stop-validating-email-addresses-with-regex/


Vim set indent

1. edit ~/.vimrc file

vi ~/.vimrc


2. And add this set of commands to the vimrc file.

set expandtab
set shiftwidth=2
set softtabstop=2
filetype plugin indent on


3. Save the changes


iptables -I INPUT -p tcp --dport 3000 -j ACCEPT

should do what you want.


If you want rules saved so after reboot all will be ok, do:

service iptables save

if you want to access without the port (ipaddress:3000) 
run this command

iptables -I INPUT -p tcp --dport 80 -j ACCEPT

then save and reboot:
service iptables save

How to install OTRS on ubuntu 12.04 server


These are steps i followed today and otrs works fine for me

wget ftp://ftp.otrs.org/pub/otrs/otrs-3.2.9.tar.gz

cp otrs-3.2.9.tar.gz /opt/

cd /opt

tar -xzvf otrs-3.2.9.tar.gz

ln -s /opt/otrs-3.0.3 /opt/otrs

useradd otrs
passwd otrs
usermod -d /opt/otrs otrs

usermod -g www-data otrs

sudo apt-get install mysql-server apache2

cd /opt/otrs

sudo ./bin/otrs.CheckModules.pl | grep Not

sudo aptitude search libdatetime-perl libnet-dns-perl libwp-useragent-determined-perl

sudo aptitude install libdatetime-perl libnet-dns-perl libwp-useragent-determined-perl

sudo bin/otrs.SetPermissions.pl –otrs-user=otrs –otrs-group=otrs –web-user=www-data –web-group=www-data /opt/otrs

sudo ln -s /opt/otrs/scripts/apache2-httpd.include.conf /etc/apache2/sites-available/otrs.conf

sudo ls /etc/apache2/sites-available/

sudo /etc/init.d/apache2 reload

sudo a2ensite otrs.conf

sudo /etc/init.d/apache2 reload


It did not work at this moment. Hence, i followed the remaining from http://wiki.otterhub.org/index.php?title=Installation_on_Ubuntu_Lucid_Lynx_ (10.4)

cd /opt/otrs/kernel
cp config.pm.dist config.pm
cp config/genericagent.pm.dist config/genericagent.pm

Modify the ENVVARS file

Add # in front of 

#export Apache_run_user=www-data
#export Apache_run_group=www-data

Below that type :

#export Apache_run_user=otrs
#export Apache_run_group=otrs

Restart Apache and you should be able to complete the registration

How to set OTRS permission

If you can’t access due to file permission of OTRS.

type this on your command line .

sudo ./otrs.SetPermissions.pl –otrs-user=otrs –otrs-group=otrs –web-user=www-data –web-group=www-data /opt/otrs

Then go to




Follow the web set up

Auto-start VIMTree when loading VIM

Goto Command Prompt

Go to Vimrc by typing              ~/.vimrc

and then add this  to the file

autocmd VimEnter * exe ‘NERDTree’ | wincmd l



open vim and VIMTree should start automatically

“Migrations are pending; run ‘bin/rake db:migrate RAILS_ENV=development’ to resolve this issue.”

To solve this issue on Rails 4.

Warning! You will lose your existing data.

      rm -f db/*.sqlite3
      rake db:create
      RAILS_ENV=development rake db:migrate
      rails s -e development

For more discuession about this errror :



Special Thanks to: http://stackoverflow.com/users/3209399/lewstherin