RubyOnRails Plugin: Auto Tags

Announcing the release of this tiny useful plugin AutoTags.
A couple of weeks ago I travelled to Mumbai in train which was a long 17hrs journey… and I utilized that by coding down the idea while travelling. So here it comes…

AutoTags, an open source project, is a plugin for RubyOnRails applications to automatically generate the relevant tags for the provided content. Its quite simple to use and provide easy integration with ActiveRecord. The plugin is very useful for social applications, community websites and all those networking applications where there is a scope of user generate content to be tagged. No more heck for the admin to sit and add the tags to the content or waiting for the users to add the tags to their content.

For installation and usage read here.

If you liked the plugin then please recommend me on workingwithrails.

April 30th, 2008   No Comments

New in Ruby 1.9: Threads

The ruby is getting changed and improved a lot with every release. No doubt the existing demerits of rails are soon going to be history.

Currently for my rails applications I am running Ruby1.8… and exploring 1.9 to get ready as we are heading with nice speed in the rails developments. Modrails has already started making waves all around.
Soon I would be publishing a couple of posts on threads, processes and sockets in ruby… here is a bit on how they are going to be different in Ruby1.9.

In Ruby1.9 the threads implementation is going to be really different than what we all know/do in Ruby1.8. The Ruby1.8 uses a single native thread and runs all Ruby threads within that… which certainly protects the Ruby threads to take on much responsibilities and to completely leverage the hardware with multiple processors.

Now, the good news, the Ruby1.9 allocates a separate native thread for every Ruby thread. But at this very moment it is not fully functional… as because of some C libraries, used here, are not thread-safe that it will not allow Ruby1.9 to take control on multiple native threads. Still, great signs of improvements in these directions… It has been mentioned that this restriction will be removed in the upcoming versions of Ruby1.9 and there will be full fledged implementation of multithreading in Ruby with multiple native threads, and the charm of parallel execution… means a lot more scope of improvements for all related libraries, frameworks built on the top of Ruby.

April 26th, 2008   No Comments

Ride the Rails: Still skeptical?

Ok, so we had been shouting ourselves hoarse, claiming that Rails is all about developer productivity and joy. So is that all about it?, huh!, was the normal reaction. But isn’t that a big enough reason. Not for many people though.

Yes, we accept that there are some pain points, like hosting Rails applications at shared hosts. No we don’t need those in production, but don’t you wish it was easier to deploy a rails app for a quick review with a client (a client who can’t run it on his own machine). Yes php scores there, just throw the code on the server and you are done. Why do I still run this blog on wordpress and not typo or mephisto? The big reason is that it’s easy to let just apache handle everything.

But things might change soon with the launch of passenger aka modrails.

And the other classic allegation against Rails has been performance. Remember the discussion between JDD and DHH about CPU cycles vs. developer cycles. We are definitely headed in the direction of lesser CPU cycles for our Rails app. Rails2 made some advances towards that and with Ruby1.9 and YARV and Rubinium, we have high expectations. Also you have heard about Ruby Enterprise Edition , haven’t you?

So things might change, when people try to figure out the fastest web language or framwework , the next time around.

I and those around me here, are generally biased towards rails. Ruby makes us happy. For us the pleasure points in Rails were always far more than the pain points. The basic Rails principles of DRY and Convention Over Configuration clicked with us. Ruby’s and Rail’s simplicity and beauty clicked with us. We did not need hosting on shared hosts. We could work with Rails caching to improve performance. No wonder we were one of the early adopters of Rails in India. But today, I would like to thank the critics whose untiring rants have moved Rails in the direction of being much more than what is was a couple of years ago.

Some of those changes have been in rails, but more have been around it. If you would have noticed, most of these development are not in rails as such, but in the ruby ecosystem.

Rails provides developer productivity and joy; ease of deployment; and ever-improving performance. And no, now you don’t need to go back to Java. We knew it, I am just repeating it for you.

Extrapolate this one year old graph for yourself.

So what is your reason for not having rail-ed yet?

Update: Charles Nutter has a post on upcoming Ruby implementations here

April 26th, 2008   No Comments

Git Error: trailing whitespace, indent SP followed by a TAB, unresolved merge conflict

I have been using Git from last few days, and faced following errors while committing:

1) Trailing whitespace
2) Indent SP followed by a TAB
3) Unresolved merge conflict

The first error “Trailing whitespace” is because of carriage-return/line-feed(windows style line feed/end). To resolve this problem comment following lines(58-60) in .git/hooks/pre-commit file:

The second one “Indent SP followed by a TAB” is because of leading spaces/tabs. To resolve this problem comment following lines(61-63) in .git/hooks/pre-commit file:

The third one “Unresolved merge conflict” is because of seven or more successive occurrence of = or < or > characters. Major chances of having seven = character in README or doc files. To resolve this problem replace following line(64) in .git/hooks/pre-commit file:

by

These tricks worked for me, I hope it could help you.

April 23rd, 2008   No Comments

Rails Plugin Annotate Models For Spec And Spec Fixtures

I have been using “Annotate Models” rails plugin written by Dave Thomas since I found it around one and half year ago. It really helps while writing fixtures. But if you use RSpec you might miss schema info at the top of your rspec fixture file as I do. So, today I modify the plugin file so that it prepends schema info to spec file and fixture file. Below are the links of patch file:

svn patch to add schema info to spec file and spec fixture file
git patch to add schema info to spec file and spec fixture file

April 23rd, 2008   No Comments