Archive for the ‘Technical Articles’ Category
How to Install Ruby on rails in your system
Contributor : Nagendra
Do following steps to setup rails environment in the local system
1) CSV : Git and Subversion
sudo aptitude install subversion
sudo apt-get install git-core
And you can also installed the suggested package
: git-doc git-arch git-cvs git-svn git-email
git-daemon-run git-gui gitk gitweb diff-doc.
1) Database setup:
Mysql database: sudo aptitude install mysql-server mysql-clientPostgresSQL: sudo apt-get install postgresql postgresql-client postgresql-contrib sudo apt-get install pgadmin3 sudo apt-get install libpq-devrefer link http://hocuspokus.net/2007/11/install-postgresql-on-ubuntu-7103) Development IDE : Netbeans First download the latest version for Ruby onhttp://www.netbeans.org/ and install it with sh. You need Java to run Netbeansfrom command prompt type:sudo sh ./netbeans.sh (path where your netbeans exists))1) Now lets install Ruby on Rails:in the Terminal (Applications -> Accessories -> Terminal) key in the following commands #sudo su #apt-get install build-essential #apt-get install ruby rdoc libopenssl-ruby #wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz #tar zxvf rubygems-1.3.7.tgz #cd rubygems-1.3.7 #ruby setup.rb #ln -s /usr/bin/gem1.8 /usr/local/bin/gem #gem install rails -v 2.3.8 This should install rails 2.3.8 version. Now we can install desired gems for the databases we use either postgres or mysql:MySQL gem: sudo gem install mysqlPostgres gem: sudo gem install postgres-pr sudo gem install postgresThats it this should be able help you install rails development environment.
Ruby enterprise edition + Passenger installation
Contributor : Vinayan
Ruby enterprise edition can be installed on the server using the following steps :
$ wget http://rubyforge.org/frs/download.php/68719/ruby-enterprise-1.8.7-2010.01.tar.gz
$ tar -zxvf ruby-enterprise-1.8.7-2010.01.tar.gz
PS: Make sure that the patch is installed on the server. If it doesn’t exist then install it via yum.
$ yum install patch
$ ./ruby-enterprise-1.8.7-2010.01/installer
Once the ruby enterprise edition is installed , the following message will appear :
“Ruby Enterprise Edition is successfully installed!”
Capistrano deployment with subversion
Contributor : Vinayan
Capistrano Deployment
Capistrano is a tool used for automation of the application deployment process. Capistrano is mainly used for deploying rails apps. Changes made to the rails app can be easily transferred to the server using cap deploying. Capistrano can be configured with any version control system like SVN / GIT for deploying an app. Also, we can define application server type (mongrel, mod_rails / Fcgi) on which the app has be deployed in Capistrano. Here I’m going to discuss cap deploying an app using SVN with Mongrel cluster as the application server.
Welcome Rails 3.0
As of December 23, 2008, the Merb (Mongrel + Erb) project is being merged with Rails, and a version with the best features of both will be released in 2010 under the name Rails 3.
Main additions in Rails 3.0
- Brand new router with an emphasis on RESTful declarations
- New Action Mailer API modeled after Action Controller
- New Active Record chainable query language built on top of relational algebra
- Unobtrusive Javascript helpers with drivers for Prototype and jQuery




Configure Sphinx in Rails application
Contributor : Nagendra
Install Sphinx
Just run the following three commands on your server or dev machine to install Sphinx:
./configure make sudo make installThat will setup Sphinx with default for use with MySQL. If you want to use it with PostgreSQL, then run
configurewith the following flag:./configure --with-pgsqlNote: you can download the sphinx from http://sphinxsearch.com/downloads/beta/Install Thinking Sphinx
Even though there are a couple of Sphinx plugins for Rails, I chose to go with Thinking Sphinx, as it seems to be the most popular and feature complete.
So you can install it as a Rails plugin using
script/plugin installcommand:script/plugin install git://github.com/freelancing-god/thinking-sphinx.gitWriting code to use sphinx search:
We now need to index our models. This consists of adding a few small lines of code into each model that you want to be able to search. So lets say we have a Blog app (doesn’t everyone!), which has a Post model. And that Post model contains the usual
titleanddescriptionfields. We therefore add the following bit of code beneath our association declarations inapp/models/post.rb:define_index do indexes title, description end
Those very short three lines will tell Thinking Sphinx to index the
titleanddescriptionfields of thePostmodel, and allow us to search through all our posts. Now we just need to index and start Sphinx. And Thinking Sphinx makes this very easy with it’s handy Rake tasks.Just run this:
rake ts:rebuildThat will stop (if it is started), index and start Sphinx for you. Now we need to create a quick search form. This will eventually be a global site search, and not just a Post search. So we will create a new controller:
script/generate controller searchThen create a view at
app/views/search/index.html.erband place the form within it:Now in your new Search controller, create a new
createaction:def create @posts = Post.search params[:search] endCreate your
createview atapp/views/search/create.html.erbwith a bit of code to display your@postsin the usual way.Note:
We can even paginate our results using the WillPaginate plugin:
def create@posts = Post.search params[:search], :page => params[:page], :per_page => 10 end