04 Mar 2008

Ruby interface for OpenSSL

openssl, ruby, ubuntu posted by SUR

If you have installed ruby using apt-get or if you have not mentioned the configuration option for openssl while installing from source, you can expect openssl will not work with ruby.

Here is the solution for the same…

Step 1

Install gcc and make(if you don’t have already on your box)

Step 2

Install the system level OpenSSL and dev libraries

Step 3

Install the ruby’s openssl interface to the system’s openssl

switch the directory to the ruby’s source code’s openssl

install the ruby’s openssl interface

try requiring the openssl in irb

if returns true, installed successfully!

23 Jan 2008

Migration: Adding/Removing columns are now much easier

RubyonRails, Technology, migration, rails, ruby, web development posted by Akhil Bansal

You may have noticed by now, that in Rails 2.0 changeset 7422, you can specify columns you want to add/remove in your migration by passing attribute:type pairs to the migration generator.

For example, lets assume that we need to add a column ‘role’ in users table(User model). In this case generate a migration like:

Output:

Here AddRoleToUser plays the main role. ‘Add’ specifies the we want to add column(s) and ‘User’ separated by ‘To’ specifies the table.

Similarly, if we need to remove a column ‘role’ :

Output:

Here RemoveRoleFromUser plays the main role. ‘Remove’ specifies the we want to remove column(s) and ‘User’ separated by ‘From’ specifies the table.

Isn’t it cool?

14 Jan 2008

Ruby Script for SVN commit notification with log message, list of updated files and readable colored SVN Diff

RubyonRails, Technology, Tools, notification, rails, ruby, subversion, web development posted by Akhil Bansal

Some days ago I wrote a post about “SVN commit notification” which uses a perl script for sending commit notification with svn diff by mail. In this mail you can find svn diff from the last committed revision. I used to love this mail, soon I realized that it is a bit ugly and difficult to read. Also there were some important information missing. Like the name of user committing the code, the log message etc…

And then I started writing my own ruby script for same purpose but with some addition and modification. Commit notification script is that script, you can download and configure it with your SVN post commit hook as follows.

Add following line at the bottom of your post-commit file:

* Please remember to change the path of you commit-email ruby script.

Now open commit-email ruby file and modify the following section according to your requirement:

You are done with that, now onwards whenever someone commits the code, you’ll get the commit notification mail like:

Commit Email Preview

08 Jan 2008

Defining function inside a function using def

ruby posted by SUR

The function(s) defined within a function works fine with any hierarchy only within the main object but gives NoMethodError inside a class.

Lets exemplify it!

Here are the example of both main object and inside a class…

Its an unexpected behavior in the main object. I don’t know whether its a bug or the feature. But as Matz says it will be removed in the future version of ruby, might be in 2.0

05 Nov 2007

Two best online API/Rails API

API, RubyonRails, ajax, rails, ruby posted by Akhil Bansal

Today I found two best API sites. One is http://www.gotapi.com.
This site provides APIs of almost all languages.

The other API site which is only focused on Rails is http://www.railsbrain.com/. I like this most. You can also download this API. It is AJAX based fast, useful.

Next Page »« Previous Page