” Installing Ruby on Rails on Ubuntu 10.04″

Posted by Piyush Gupta on July 21, 2010

There are a few different approaches to installing Ruby on Rails on Ubuntu 10.4. This is the technique that I use, in my opinion it involves the least hassle.

Ubuntu has a managed ruby package that serves perfectly as the basis for a Ruby on Rails installation. Open a console and install it with the following command.

sudo apt-get install ruby-full build-essential

I’ve previously had issues with the rubygems Debian package and would normally advocate installing the package directly from RubyForge.

cd ~
mkdir gems
cd gems
wget http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz
tar -xf rubygems-1.3.7.tgz
cd rubygems-1.3.7
sudo ruby setup.rb

The ruby setup script doesn’t automatically place a link to the gems application in your /usr/bin folder so add it now.

sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

Update your ruby environment. If you’ve downloaded the latest version of rubygems, you’ll be told that everything is already up-to-date.

sudo gem update system
gem -v

With your ruby environment ready, install rails.

sudo gem install rails

You’re finally at the point where you can create rails projects, just use the following command.

rails test_project

I prefer to use something a bit more friendly than vi as a development environment for Rails. Download and install the latest copy of Netbeans from netbeans.org.

wget http://download.netbeans.org/netbeans/6.9/final/bundles/netbeans-6.9-ml-linux.sh
chmod +x netbeans-6.9-ml-linux.sh
./netbeans-6.9-ml-linux.sh

“Learning Rails”

Posted by Piyush Gupta on July 19, 2010

We all use Agile web development , ruby for rails, rails in 4 days, ruby , ajax etc books to get a hang of ruby on rails also some more books like pragmatic etc .

However I thought of making a list of websites which help do so

So here is the bunchedin : http://www.bunchedin.com/vuIMCc

“Installing ImageMagik on Unix/Linux” 1

Posted by Piyush Gupta on July 15, 2010

Follow the below steps

wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz

Next configure and compile ImageMagick:

tar xvfz ImageMagick.tar.gz
cd ImageMagick-6.6.3
./configure
make

If ImageMagick configured and compiled without complaint, you are ready to install it on your system. Administrator privileges are required to install. To install, type

sudo make install

Finally, verify the ImageMagick install worked properly, type

/usr/local/bin/convert logo: logo.gif

For a more comprehensive test, run the ImageMagick validation suite. Ghosts cript is a prerequisite, otherwise the EPS, PS, and PDF tests will fail.

make check

Reference : http://www.bunchedin.com/aOqNOv

“Simple MYSQL commands” 2

Posted by Piyush Gupta on July 05, 2010

Here I shall be jotting down one by one simple SQL commands that we use .

Check the comments .

“Error in ruby relative_path_from call on windows”

Posted by Piyush Gupta on June 28, 2010

I was playing around with “SPREE COMMERCE”after a long term on my windows machine , before this have always used my linux box for Spree commerce .

However got stuck at the very first step after bootstrapping a fresh application .

Error :

After scratching head for long and loosing 20 hairs atleast drilled down to source of error and monkey patched the error .

Moreover after a little digging, it was evident that the ‘relative_path_from’ method in ‘/ruby/lib/ruby/1.8/pathname.rb’ file had the problem. The problem was also described as a ticket at http://redmine.ruby-lang.org/issues/show/1366 and the excerpt of the issue is shown below:

Monkey Patch :

I added the capitalize! keyword at the end of the two lines so that both the paths are in uppercase, so that later in the code ( ) shown below does not barf and give us the error we got shown in the first error of the post.

Overriding original :

“Sending email with Ruby on Rails 2.3.5 and gmail”

Posted by Piyush Gupta on June 23, 2010

If you need an easy way to setup email for your company or for a client it’s hard to not love Google Apps. (The ’standard’ ie free version is here).

It is very likely that at some point you will need to send out emails from your application. Don’t cry. Gmail can do this for you. Rails 2.3.2 makes it easier than ever with the addition of ‘enable_starttls_auto’. Put the following code in production.rb, development.rb or environment.rb and you ’should’ be able to send out emails:

If you are one of the lucky ones this will actually work. It didn’t work for me but since I still needed to get email working here’s what I did:

First be sure to activate the email account that you are using. To do that you only need to login. Google will walk you through entering a captcha etc.

You might get this error:
Net::SMTPAuthenticationError: 530 5.7.0 Must issue a STARTTLS command first.

If you do then check your Ruby version. Ruby 1.8.7 has this built in but Ruby 1.8.6 does not.

The next best thing is to get action_mailer_tls. Most of the links you will find in forum and blog posts are broken. The code is on github and neatly packaged as a gem: http://github.com/openrain/action_mailer_tls/tree/master. Follow the directions to install and configure the plugin there and you should be able to send email.

Here’s a couple of handy conversations for reference:

http://www.railsforum.com/viewtopic.php?id=28480

http://www.ruby-forum.com/topic/184137

“New Features in Rails 3″

Posted by Piyush Gupta on June 22, 2010

We’re all about following the newest technology in web development. Rails 3 is coming soon, and it promises to be a significant upgrade. With the 4th beta version pushed recently, and a release candidate right around the corner, I thought now would be a good time to go over my two favorite new features.
All New Router

The router has been completely re-written and borrows heavily from the Merb router, but has a more developed DSL.

Regular Routes

Regular routes are more concise, but I’m not sure how I feel about the “controller#action” syntax yet…

Named Routes

Very similar to regular routes, just with an extra :as variable at the end.

Restful Routes

I think restful routes get the biggest improvement. The new syntax is MUCH easier to read than in Rails 2.

ActiveRecord and ActiveRelation

This is probably my favorite addition to Rails. The new ActiveRecord syntax is very similar to Doctrine (which we use with symfony). Instead of passing options as a hash to your find() method, they’ve created a bunch of new methods you can chain together.

The best part is that any of the query methods just return a relation instead of running the sql query. That way, you can chain more query methods on the relation later. The actual query doesn’t run until you try to access the object(s) (such as with an iterator). This makes fragment caching a lot easier, because you can keep your query call in your action. Even if the cache is hit, it will only create a relation and not actually query the database. You can also force the query to be run at any time by calling all(), first(), or last() on the relation.

“Ruby On Rails environment on Ubuntu 10.04

Posted by Piyush Gupta on June 22, 2010

I think this is my first technical post in the blog, so today I faced some problems while building the Ruby on Rails environment on my machine. I just like sharing this knowledge with you.

First, in this post we will make the following:

1. Ruby 1.9.1
2. Rails 2.3.5
3. Thin server.
4. MySQL server.

1. Ruby 1.9.1
The following commands mainly download the Ruby source code and compile it and so on

Just you have to install the following libraries:

sudo apt-get install build-essential libssl-dev libreadline5-dev zlib1g-dev

move to /usr/local/src to download source code and compile it in this folder
cd /usr/local/src

Download the source code, and unpack it

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

Now, you have to check the version of gcc if it is 4.4 some errors will occur

dpkg -l | grep gcc

if gcc 4.4 found then you have to edit the cont.c file to go on. Open it up, and change the lines 90, 270 and 317 from #elif to #else.

sudo gedit cont.c

then write the following commands in terminal

sudo ./configure –prefix=/usr/local/ruby-1.9.1
sudo make
sudo make install

After these steps you have finally installed Ruby 1.9.1, to check its version

cd /usr/local/ruby-1.9.1/bin
ruby -v
output like that: ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]

Now, the ruby commands such as ruby, rake, irb, … etc are accessed only from /usr/local/ruby-1.9.1/bin, and all the commands are found in /usr/local/bin so just make link for the commands in ruby-1.9.1/bin and put them in /usr/local/bin

sudo ln -s /usr/local/ruby-1.9.1/bin/ruby /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/rake /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/gem /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/irb /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/ri /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/rdoc /usr/local/bin

2. Rails 2.3.5
Now, Ruby 1.9.1 is installed successfully on your machine, just add this command to terminal to install the Rails 2.3.5 gem

sudo gem install rails -v=2.3.5

3. Thin server
Also to install Thin application server gem

sudo gem install thin

4. MySQL server
Finally to install MySQL server for DB

sudo apt-get install mysql-server
and while installing it is required to set the root password

References: http://www.bunchedin.com/8Bolx6

Hope that it is some how useful for you

“Some interesting threads/blogs/mails” 5

Posted by Piyush Gupta on June 18, 2010

See the comments .Whenever I stumble upon one will add in the comment .
 

“Diagrammr – Great tool for quick, sentence-constructed diagrams”

Posted by Piyush Gupta on June 18, 2010

I saw someone on twitter tweet about this useful tool that helps create diagrams with sentences you type.

Watch how easy it is:

  1. First, type in a sentence along like:

    37b5d79cdc2167bb9a93dd12b483f877

  2. After hitting , you get this diagram

    20c9bcb89ec0ed3540d5f8b7073fcfa0

  3. Try typing another

    D7faa05dc378f2ee07cee550937e4b90

  4. Easy yeah?

    509187955d42ed91245499ec24fd0516

  5. Now try to link 2 items together with a verb

    D854c9d2236e0389b9af599bd1be906f

  6. Awesome, it resizes itself nicely!

    53e54f4a3c0e0b2d6f88b36114c4111a

Try it out for free at http://diagrammr.com

Created by Freshlog Storyteller