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 install
That will setup Sphinx with default for use with MySQL. If you want to use it with PostgreSQL, then run configure with the following flag:
./configure --with-pgsql
Note: 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 install command:
script/plugin install git://github.com/freelancing-god/thinking-sphinx.git
Writing 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 title and description fields. We therefore add the following bit of code beneath our association declarations in
app/models/post.rb:
define_index do indexes title, description end
Those very short three lines will tell Thinking Sphinx to index the title and description fields of the Post model, 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:rebuild
That 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 search
Then create a view at app/views/search/index.html.erb and place the form within it:
Now in your new Search controller, create a new create action:
def create @posts = Post.search params[:search] end
Create your create view at app/views/search/create.html.erb with a bit of code to display your @posts in 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
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.
Servermascot E Store for Server Management wows its customers with great service
Within just three weeks of the successful launch of a revolutionary product by InstaCarma, ServerMascot has become an instant hit. The customers are pouring in and are very happy with the range of services and support provided by ServerMascot. A team of expert Engineers here at ServerMascot ensure that the customers get their work done in time and with utmost accuracy. ServerMascot has also received some great testimonials from the customers within this short span of its launch. Some of the testimonials include,
I’m really happy with your service, everything works perfect. Thanks for your help, soon I’ll be with you for other projects that need
Erasmo
Servermascot is reliable, diligent and professional. This company is strongly recommended!
Dylan
Thanks Servermascot, your fast delivery and efficient service is highly appreciated. We will definitely continue to hire services from you in the future too.
Saurav Gupta
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!”




Install Image-magick and rmagick for rails
Contributor : Nagendra
Start by removing any old versions previously installed via apt-get:
sudo apt-get remove imagemagick
Then update apt-get and install some supporting packages:
sudo apt-get update
*(sudo apt-get install
libperl-dev gcc libjpeg62-dev libbz2-dev
libtiff4-dev libwmf-dev libz-dev libpng12-dev
libx11-dev libxt-dev libxext-dev libxml2-dev
libfreetype6-dev liblcms1-dev libexif-dev perl
libjasper-dev libltdl3-dev graphviz gs-gpl pkg-config)*
*its a single line command.
get the Imagemagick package from this link:
http://www.imagemagick.org/script/install-source.php#unix
Once the source is downloaded, uncompress it:
tar -xzf ImageMagick.tar.gz
Now configure and make:
cd ImageMagick-6.5.0-0
./configure
sudo make
sudo make install
Add the following line to ~/.bashrc:
export LD_LIBRARY_PATH=/usr/local/lib
Update: If you still get an error like the one above, try running ldconfig:
sudo ldconfig
You can confirm the install and available formats with:
identify -list format
Once Image magick is installed install rmagick gem by typing the command:
$sudo gem install rmagick