Wednesday, September 30, 2009

--no-ri --no-rdoc for ruby gem installation

by sandipransing 1 comments
One can install gem without rdoc using

gem install GEM_NAME --no-ri --no-rdoc


Skip ri rdoc for all gem installation as i haven't seen anyone using it.

Edit gemrc file
Add following line to it
vi ~/.gemrc
:gem: --no-ri --no-rdoc


Here is my ~/.gemrc file
---
:verbose: true
gem: --no-ri --no-rdoc
:update_sources: true
:sources:
- http://gems.rubyforge.org
- http://gems.github.com
:backtrace: false
:bulk_threshold: 1000
:benchmark: false


That's it !
Read More…

Managing multiple ruby versions and rails versions with rvm

by sandipransing 2 comments
While working with many projects that uses different ruby versions and rails versions, one big problem arises that how do we manage all this ?

We know that managing multiple rails versions wont be problem at all.
but what about ruby versions, How one can manage multiple ruby versions. also while upgrading or degrading ruby version, we need to install all gems again including rails.
i know this is a big pain :(
How we can overcome this headache. meantime there must be some incompatibilities between two different ruby and rails versions.

Yesterday, i did some research and came to know that...

+ ruby 1.8.7 and rails 2.3.3 got quite stability and effectively. we can use it in next developments.
+ Also, after installing ruby 1.9.1 and dependent gems for my project,
and wondering that there are many incompatibilities while installing new gems with ruby 1.9.1

Some of the gems are mysql, ferret, acts_as_ferret, erubies, etc.

Today, while google, i found rvm gem and that seems very nice to manage multiple ruby versions.


Here are some steps explaining how to use it.

# Install rvm gem to manage multiple ruby version
# pre-requisite is that we already have ruby and rubygems installation
1. sudo gem install rvm

# Install rvm for a particular user
# It will also show how to use gem
2. rvm-install

3. Open new shell

# Show all ruby, jruby installations
4. rvm list

# Install ruby
# specify ruby version
5. rvm install RUBY_VERSION_TO_BE_INSTALLED
(rvm install 1.9.1)

# Install jruby
# By default it will install jruby-1.3.1
6. rvm install jruby

# Specify which ruby version to use ?
# Note: Be sure that ruby version is installed
7. rvm use RUBY_VERSION_TO_USE
(rvm use 1.9.1)

#. Default i.e. version before rvm gem installation
8. rvm use default

Sounds, cool :)
Read More…

Tuesday, September 29, 2009

jruby rails installation on ubuntu interpid

by sandipransing 1 comments
# install mysql if you dont have already installed
sudo apt-get install mysql-server mysql-client libhtml-template-perl mailx dbishell libcompress-zlib-perl mysql-doc-5.0 tinyca

# install ant and jdk
sudo apt-get install ant sun-java6-jdk

# install jruby
mkdir software
cd software
wget http://dist.codehaus.org/jruby/jruby-bin-1.1.5.tar.gz
tar xvfz jruby-bin-1.1.5.tar.gz
ln -s jruby-1.1.5 jruby
export PATH=$PATH:$HOME/software/jruby/bin

# install the version of rails wanted by jruby
jruby -S gem install jruby-openssl
jruby -S gem install rails

# list your gems
jruby -S gem list

# install the gems needed for db
jruby -S gem install activerecord-jdbc-adapter activerecord-jdbcmysql-adapter

# generate some code
cd ~/scripts/ruby
jruby -S rails wherehaveyoubeen -d mysql
cd wherehaveyoubeen
jruby script/generate controller states index

# configure access to the database server
vi config/database.yml

#development:
# adapter: jdbcmysql <- very important!
# encoding: utf8
# database: test_development
# username: root
# password: database
# socket: /var/run/mysqld/mysqld.sock

# generate the db
jruby -S rake db:create:all
jruby -S rake db:migrate


# edit your app
sudo apt-get install emacs ruby-elisp irb1.8 emacs22-el
emacs -bg black -fg wheat app/views/states/index.html.erb

# uncomment the secret in app/controllers/application.rb
vi app/controllers/application.rb

# run your app
jruby script/server
Read More…

upgrading rails version

by sandipransing 0 comments
Here are the simple steps to be followed while upgrading rails version to use.

# Install rails version
1. gem install rails -v
== gem install rails 2.3.3

# Upgrade environment.rb for new version
2. RAILS_GEM_VERSION = '' unless defined? RAILS_GEM_VERSION
== RAILS_GEM_VERSION = '2.3.3' unless defined? RAILS_GEM_VERSION

# Upgrade necessary files for the new version
3. rake rails:upadte

# Start server
4. /script/server


Thats, it !
Read More…

Installing ruby 1.9.1

by sandipransing 0 comments
installing ruby 1.9.1 is very easy .......
follow simple steps

wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.gz

tar -xvf ruby-1.9.1-p0.tar.gz

cd ruby-1.9.1-p0
./configure

make
make test
sudo make install


Thats, it !
Read More…

Friday, September 25, 2009

Migrating project from rails 2.1.0 to edge rails 2.3.3

by sandipransing 1 comments
I wanted to migrate my project from rails 2.1.0 to rails 2.3.3
so, i performed following steps, but it shows me memcached-client error.

vi config/environment.rb

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.3' unless defined? RAILS_GEM_VERSION


ruby script/server

It shows me error
`install_memcached': 'memcache-client' client requested but not installed. Try 'sudo gem install memcache-client'. (Interlock::ConfigurationError)

so, i installed memcache-client gem

gem install memcache-client

but still i am showing same error, any ideas ??
Read More…

Monday, September 21, 2009

Thank You

by sandipransing 0 comments
Thanks for your valuable feedback!
Read More…

Contact Me

by sandipransing 0 comments
I would be thankful to you for any suggestions or advice you give for the improvement of this blog !

Your Name
Your Email Address
Website/Blog
Subject
Message
   

Read More…

Monday, September 14, 2009

Watch live India vs Srilanka cricket

by sandipransing 0 comments
http://watch-online-cricket.blogspot.com/2009/01/watch-india-vs-srilanka-cricket-online.html
Read More…

Wednesday, September 9, 2009

4 steps to install nginx with passenger

by sandipransing 2 comments
Install passenger program that will run your rails application
1. sudo gem install passenger
Install nginx server with passenger enabled
2. passenger-install-nginx-module

it will open apt, click "Enter" to contine
then select option 1 for default install
then it will ask
Where do you want to install Nginx to?

Please specify a prefix directory [/opt/nginx]:
press enter

then copy following block

server {
listen 80;
server_name www.yourhost.com;
root /somewhere/public;   # <--- be sure to point to 'public'!
passenger_enabled on;
}


Make nginx Configuration
3. vi /opt/nginx/conf/nginx.conf
Make passenger_root and passenger_ruby path to configuration


http {
passenger_root /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.4;
passenger_ruby /usr/local/bin/ruby;


then add server configuration block inside http block
http{
...
server {
listen 80;
server_name www.yourhost.com; //Make sure this dns entry inside /etc/hosts
root /carsonline/public;   # <--- be sure to point to 'public'! //here carsonline is RAILS_ROOT
passenger_enabled on;
}


Thats, all

4. Launch Server

/opt/nginx/sbin/nginx
Read More…

How do i generate SEO sitemap in rails ?

by sandipransing 6 comments
What is sitemap ?

Sitemap is nothing but a .xml file containing urls available on your site

It contains URL, last modified date, frequency of content change and priority ( between 0..1 )

Why we need sitemap ?

We can submit sitemap file to search engine. It will help them in analysing what urls on your site are available for crawling.

What is xml pattern ?
   <?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

<url>
<loc>http://www.example.com/</loc>
<lastmod>2005-01-01</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
...
...
</urlset>

What will be the path for sitemap ?

"www.example.com/sitemap.xml"

Are we going to generate sitemap manually ?

No... there is mephisto sitemap plugin.We can use it.

script/plugin install http://svn.appelsiini.net/svn/rails/plugins/mephisto_sitemap/

Am i needed to generate to sitemap for each request ?

No ...........we can generate it in background task daily basis.

How it will be accessed for request to sitemap ?

we can define path to local file in routes.

map.connect "sitemap.xml", :controller => :sitemap

Class SitemapController

def index

render "some local file path"

end

....

Here are the reference links

http://www.fortytwo.gr/blog/19/Generating-Sitemaps-With-Rails

http://www.bestechvideos.com/2008/07/04/ruby-plus-71-how-to-create-a-seo-sitemap-for-rails-apps
Read More…

Friday, September 4, 2009

Social Media Overview

by sandipransing 1 comments
[gigya width="425" height="355" src="http://static.slideshare.net/swf/ssplayer2.swf?doc=socialmediaoverview-mar09-090325125549-phpapp01&stripped_title=social-media-overview-1197231" quality="high" wmode="tranparent" ]
Read More…

Wednesday, September 2, 2009

What is new in edge rails 2.3.3 ?

by sandipransing 1 comments
Rails community has released rails 2.3.3 recently with major upgrades and several bug fixes added.

On the other side, Rails 3 ( i.e. merge of rails and merb framework ) is supposed to be officially get released in this May.

Lets see what are the notable features added in rails 2.3.3

1. Rack

What is this rack ?

Abstraction built on the top of rails framework

What it does ?
It provides minimal interface between webservers supporting ruby ( like  apache-mongrel, nginx-passenger ) and rails framework.
Gives access to middleware goodness
i.e. wrapping HTML requests and response in simple way
unifies and distills the API for web servers, web frameworks, and software in between

read more ...

2. Metal
It is a subset of rack middleware specially designed to integrate with rails    application.

Why to use it ?
Whenever you need achieve raw speed for certain requests by skipping action controller stack.
read more ...

3. Engines
It was a plugin that got merged in rails core.
It is used for sharing controllers, models and views seamlessly from within a plugin to your rails application.
read more ...

4. Templates
These are the ruby files which describes which gems, plugins and initiliazers  has to be added while creating new rails project.
read more ...

5. Nested Forms
Earlier nested forms for has_one and has_many associations wasn't
there in rails.
this release added nested forms complex associations in models.
read more ... also see ...

One of good rails architecture diagram found while google


[caption id="" align="alignnone" width="460" caption="Rails 2.3 architecture diagram"]Rails 2.3 architecture diagram[/caption]

Edge rails Installation
gem install rails --source http://gems.rubyonrails.org

Thanks to rails community  for bringing this things in rails core.
Cheers, now rails is getting its way !
Read More…

About The Author

Sandip is a ruby on rails developer based in pune and also a blogger at funonrails. Opensource contributor and working with Josh software Private Limited. for more info read Follow Sandip on Twitter for updates.

Connect With Me...

Github Projects

@sandipransing Twitter