Veerasundaravel's Ruby on Rails Weblog

February 15, 2010

Rails3 Beta installation

This post will explain how I proceeded with latest beta version Rails3 and the issues I faced.

My current version of rails and ruby:

veera@client25:~$ rails -v
Rails 2.3.5
veera@client25:~$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
veera@client25:~$

trying to install beta version of rails3.

gem install tzinfo builder i18n memcache-client rack  rake rack-test rack-mount erubis mail text-format thor bundler
gem install rails –pre

I forget to add sudo, so that I got so many errors. Let me try with sudo.

Ok some what better am getting error message only while installing generating documentation for builder-2.1.2

gem install rails –pre – was not successfull. As it haven’t installed rails3 version as I expected.

Getting error like below:

WARNING:  RubyGems 1.2+ index not found for:

RubyGems will revert to legacy indexes degrading performance.
Updating metadata for 1 gems from http://gems.rubyforge.org/

surfed google for the error, http://bparanj.blogspot.com/2008/11/warning-rubygems-12-index-not-found-for.html

lemme try the idea mentioned in that

veera@client25:~$ sudo gem sources -a http://gems.github.com
http://gems.github.com added to sources
veera@client25:~$

or else remove all the gem sources from you location, so that it can any of the source directly from net

I assume installing sudo gem install rack-mount –version=0.4.0, solved my issue.

Now I can see that rails3 is installed in my machine.

after this try the following options:

$ sudo gem install tzinfo builder memcache-client rack rack-test erubis mail text-format bundler thor i18n
$ sudo gem install rack-mount –version=0.4.0
$ sudo gem install rails –pre
$ rails -v
Rails 3.0.0.beta

then create the app in rails3 version

rails RailsBeta3

I can find a new file application.rb under config directory. Seems we have to use it instead of environment.rb

* Issues found:

1. Couldn’t find support for postgresql with Rails3.
2. Not able to start the rails app using mongrel_rails start.

My initial scaffold is working fine. rails generate scaffold group title:string description:text

Referred http://www.slideshare.net/GreggPollack/rails-3-beautiful-code-3219240 for the updated methods and options in Rails3.l,
Cool, simply and effective slide show about Rails3. Some of the important points from that:

1. ruby script/* is modified as rails(ex ruby script/server -> rails)
2. amazing and simplified routes. map.resources is modified as resources and lot more.
3. Improved syntax for respond_to method.
4. Simplified action mailer option.
5. Active record syntax is also modified, Person.all(:conditions=>”blah blah) to Person.where(“blah blah”)
6. form_remote_tag, link_to_remote tag is also simplified and the respective html source is also looks very simple. (no more onclick”new Ajax request ………..”)

looking for few more documents for the modified methods in rails3.

Tried to generate a gem in Rails3.

restful-authentication plugin is not working in rails – May be auth_logic plugin will work.

Grrrrrrr, I can’t create a older version of rails app  – rails _2.3.5_ blog235

/usr/local/lib/site_ruby/1.8/rubygems.rb:827:in `report_activate_error’: RubyGem version error: railties(3.0.0.beta not = 2.3.5) (Gem::LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems.rb:261:in `activate’
from /usr/local/lib/site_ruby/1.8/rubygems.rb:68:in `gem’
from /usr/bin/rails:18

Hope rails3 alpha version should have fix for this. So now am reverting back to old version of rails by simply uninstalling all the gems related to rails3.

Advertisements

June 20, 2008

Installing sphinx in linux environment

Login as root!

apt-get install build-essential gcc

# Add new system user sphinx
adduser –system –home /var/sphinx –uid 999 –disabled-password –disabled-login –group sphinx

# Create the dirs
mkdir /var/sphinx/bin
mkdir /var/sphinx/etc
mkdir /var/sphinx/log
mkdir /var/sphinx/lib
mkdir /var/sphinx/run

# Download and compile sphinx
wget http://sphinxsearch.com/downloads/sphinx-0.9.8-rc2.tar.gz

tar -xzvf sphinx-0.9.8-rc2.tar.gz

cd sphinx-0.9.8-rc2

./configure

make

make install

# Install sphinx binaries
cp src/indexer src/search src/searchd /var/sphinx/bin/

# Install sphinx configuration (remember to edit as it needs)
cp sphinx.conf.dist /var/sphinx/etc/

# Copy the startup script attached below, instead of attaching I posted that file as another post (https://veerasundaravel.wordpress.com/2008/06/20/sphinx-startup-script-related-to-sphinx-installtion/)
copy that post content and save as a init script file named sphinx

mv sphinx /etc/init.d/

chmod 755 /etc/init.d/sphinx

# This shows your run level
/sbin/runlevel | cut -b 3

# Lets say it is 2…
ln -s /etc/init.d/sphinx /etc/rc2.d/S92sphinx

# Add the correct ownership to sphinx
chown -R sphinx:sphinx /var/sphinx

# Give some restrictions…
chmod -R 711 /var/sphinx/

# Ok we almost done!!
cd /var/spinx/etc

cp -p sphinx.conf.dist sphinx.conf

# And edit this entries in sphinx.conf to look like this:

sql_host                                = localhost
sql_user                                = root
sql_pass                                = (your password)
sql_db                                  = (your database name)
sql_port                                = 3306  # optional, default is 3306

# In section searchd

pid_file = /var/sphinx/run/searchd.pid

query_log = /var/sphinx/log/query.log

log = /var/sphinx/log/searchd.log

address = 127.0.0.1

# section index
path = /var/sphinx/lib/sphinx

Continue to edit the configuration and when you are ready…

Then start sphinx using the command!

/etc/init.d/sphinx start

now you are ready with sphinx, now you can install plugins like acts_as_sphinx, ultrasphinx etc to easily interact with sphinx using your rails application.

Sphinx startup script related to sphinx installtion

Continuing my last post Installing sphinx – https://veerasundaravel.wordpress.com/2008/06/20/installing-sphinx-in-linux-environment/

Here the startup script for the sphinx search engine.

#! /bin/sh
# /etc/init.d/sphinx: start the sphinx search daemon.

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin

pidfile=/var/sphinx/run/searchd.pid
binpath=/var/sphinx/bin/searchd

SPHINX=”–config /var/sphinx/etc/sphinx.conf”

NAME=searchd
DESC=”sphinx search daemon”

test -f $binpath || exit 0

test ! -r /etc/default/sphinx || . /etc/default/sphinx

running()
{
# No pidfile, probably no daemon present
#
if [ ! -f $pidfile ]
then
return 1
fi

pid=`cat $pidfile`

# No pid, probably no daemon present
#
if [ -z “$pid” ]
then
return 1
fi

if [ ! -d /proc/$pid ]
then
return 1
fi

cmd=`cat /proc/$pid/cmdline | tr “00” “\n”|head -n 1`

# No syslogd?
#
if [ “$cmd” != “$binpath” ]
then
return 1
fi

return 0
}

case “$1” in
start)
echo -n “Starting sphinx search daemon: searchd”
start-stop-daemon –start –quiet –chuid 999 –group 999  –exec $binpath — $SPHINX
echo “.”
;;
stop)
echo -n “Stopping sphinx search daemon: searchd”
start-stop-daemon –stop –chuid 999 –group 999 –retry TERM/1/TERM/1/TERM/4/KILL –quiet –exec $binpath –pidfile $pidfile
echo “.”
;;
restart|force-reload)
echo -n “Restarting sphinx search daemon: searchd”
start-stop-daemon –stop –chuid 999 –group 999  –retry TERM/1/TERM/1/TERM/4/KILL –quiet –exec $binpath –pidfile $pidfile
start-stop-daemon –start –chuid 999 –group 999  –quiet –exec $binpath — $SPHINX
echo “.”
;;
*)
echo “Usage: /etc/init.d/shpinx {start|stop|restart|force-reload}”
exit 1
esac

exit 0

%d bloggers like this: