Showing posts with label Ruby On Rails. Show all posts
Showing posts with label Ruby On Rails. Show all posts

Wednesday, November 14, 2012

Ruby on Rails is for Toy Apps. Wtf!

I recently met a guy who told me that "We are making our product in java. I've a great software architect (who develops in java) who told me that Ruby on Rails is for data driven toy applications but when it comes to serious business apps, we use java".

This is not the first time I'm hearing this... So many java developers have been spreading this propaganda that Ruby on Rails applications are slow which is non-sense because the only thing that makes an application slow is the nut coding it.

I've coded in C++, MFC, java and .net before I started coding in Ruby and I've seen many obvious benefits that Ruby and Ruby on Rails gives to the coder and the code -
1. Readability
2. A long list of plugins - Gems we call them. Just think of a use case and there's a already a gem which does that.
3. Speed of development - You start seeing considerable progress within half an hour.
4. Agility - Ruby on Rails has agility at its core given the features of data migrations and built-in unit test suite.

I don't have the stats around it, but I haven't seen any developer community more paranoid about TDD and BDD than ruby community which is the foundation of Agile development and quality code.

Heard that Ruby is slower than Java?
1. There is JRuby - the java implementation of Ruby - it bridges the gap.
2. Did you know that most of the heavy lifting is done in C? And that ruby makes it very easy to wrap in your native extensions as Ruby gems?

So, the next time your java engineers tell you that Ruby / Ruby on Rails is for toy apps. Well, say wtf!

Saturday, April 21, 2012

Deploying a Rails Application on Red Hat Server using RVM, NGINX, Passenger, Oracle, SVN


Using Red Hat? Oracle? SVN (When there's git!)?
Its a pain, here's the answer.

#Add EPEL to yum
rpm -ivh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
yum update

# Create the rvm group and add any users who will be using rvm to the group
sudo su -
groupadd rvm

# Start by adding the root user (required to install RVM)
usermod -a -G rvm root

# Then add any other users who need access to to the rvm group and logout of the superuser account
logout

#Now install RVM
curl -L get.rvm.io | bash -s stable

#Load RVM:
$ source ~/.rvm/scripts/'rvm'

#install git
rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm
sudo yum install --enablerepo=webtatic git


#install ruby - takes some time...
rvm install 1.9.3
rvm use 1.9.3 --default

#install bundler
gem install bundler

gem install rails -v 3.1.0

#fetch the application. Goto your deployment directory and do
svn checkout

#Edit the rails configuration files:
config/environments/production.rb
config/database.yml

#install Oracle
#Get the instant client packages from Oracle and do the following
sudo rpm -i oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
sudo rpm -i oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm
LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib/
export LD_LIBRARY_PATH

#install the gems
bundle install

#Precompile assets
rake assets:precompile RAILS_ENV=production

#create the service_log directory
mkdir log/service_log

#now we need to get some permissions straight
chmod -R 777 tmp
chmod -R 777 log/service_log

#install passenger
gem install passenger

#install nginx. Accept all the defaults
rvmsudo passenger-install-nginx-module

#Here's the nginx conf file /opt/nginx/conf/nginx.conf
#Here are some helpful locations
# passenger_root /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.12;
# passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.3-p125/ruby;

#Copy the config file
sudo cp /opt/nginx/conf/nginx.conf /opt/nginx/conf/nginx.conf.bak
rm /opt/nginx/conf/nginx.conf
cp installation_dump/nginx.conf /opt/nginx/conf/nginx.conf

#update the configurations (eg. the rails app public path, port number, server name etc. and stuff similar to what you might be doing with java web servers)
nano /opt/nginx/conf/nginx.conf

#Copy the nginx start/stop helper script
sudo cp installation_dump/nginx /etc/init.d/

#finally
sudo /etc/init.d/nginx start

#Troubleshoot - if you see nothing after start you can debug using
sudo /etc/init.d/nginx configtest

Friday, August 5, 2011

Google+ style circles Drag Drop using Rails

A working example for Google+ style circles drag drop using Rails 2.3.

The only challenge was how to make the Draggable elements drag across a scrollable div.
It was solved by using the library at http://scripteka.com/script/dragdropextra