Over the years a pattern has emerged in my utilization of Rails plugins. These plugins have become so essential to my development workflow, that I can’t image creating a Rails app without them.
1. Will Paginate
The quintessential paging module for Rails views. If you aren’t using WIll Paginate, you haven’t built any real Rails project, dude. Pagination used to be built in, but the implementation was rather flawed, so Will Paginate was created. Over the years it has been immensely fine-tuned. As far as I know there is no competition and Will Paginate is rock stable.
Installation: To enable the library your Rails 2.1 (or greater) project, use the gem configuration method in “config/environment.rb”
Rails::Initializer.run do |config|
config.gem 'mislav-will_paginate',
:version => '~> 2.3.11',
:lib => 'will_paginate',
:source => 'http://gems.github.com'
endTo install this gem (and all other missing gem dependencies), run rake gems:install (use sudo if necessary). Also, don’t forget to restart your webserver after editing environment.rb.
2. Paperclip
First you had upload_column, then attachment_fu, now Paperclip. This plugin saves you all the trouble with file uploads in Rails (well, except asynchronous progress bar). Add at a minimum the upload_file_name to any database table, add a class method to your model and you’re all set. While attachment_fu, my previous favourite, is pretty good, there still is a fair amount of code plumbing required to get it to work. Paperclip gets rid of all unnessesary code and it even allows batch upload in a rakefile. Incredibly useful when you’re importing stuff from a previous storage method.
installation:
config.gem 'thoughtbot-paperclip',
:lib => 'paperclip',
:source => 'http://gems.github.com'
3. Authlogic
First you had nothing, then came restful authentication. Now you just use Authlogic. This is the one authentication module to bind them all. It’s restful by design instead of just by name and doesn’t introduce any foreign code into your application. It has support for perishable tokens and is just plain better designed than other solutions. I use it exclusively on all my current Rails websites and have no issues. I also use it for some heavy-lifting Single Sign On magic and so far it has played along nicely with everything I have thrown at it. If you need to know who a certain user is, you have to use this gem.
Installation:Install the gem / plugin (recommended)
From rubyforge:
sudo gem install authlogic
Or from github:
sudo gem install binarylogic-authlogic
Now just add the gem dependency in your projects configuration.
4. Acts as Taggable On
First you had built-in tagging, then came tagging on steroids. Now just use Acts As Taggable On. In addition to regular tag functionality, it introduces a context for your tag. This means I never need to create any kind of Category model ever again. In fact, if I find myself creating a Category, it’s a warning sign that I need to re-think what I’m doing and just implement a new context for acts_as_taggable_on. Whether I have to allow position placement for content (“on the homepage”, “on the about page”) or allow a category for a review (“cd review”, “dvd review”) or just plain allow a user to tag content, Acts As Taggable On is the way to go. The developer took care to index the database table as well, so performance is not a problem.
script/plugin install git://github.com/mbleigh/acts-as-taggable-on.git
5. Title Helpers
This is a small and unknown plugin, but it saves me much time doing Search Engine Optimisation, plus it makes my controllers and views much cleaner. It allows me to set the page title rather quickly, and warns me in development mode to do just that. Since it’s the small things that matter, Title Helpers is something I use on every project.
install:
script/plugin install git://github.com/mcmire/title_helpers.git
6. Searchlogic
The most recent addition to my toolbox, Searchlogic makes searching models a breeze. No, it’s not a full text search solution (there is no perfect solution at the moment) but instead Searchlogic provides a nice set of pre-defined named scopes which simply database searches such as “all users greater than 21 years” or “all articles published after today”. The real killer feature though it that Searchlogic re-uses my own named scopes and makes them chainable through associations. A mouthful of tech mumbo-jumbo, yes, but I couldn’t imaging coding without this feature! An example?
Serie.visible.afleveringen_yesterday
This method searches all Series that are visible and have Afleveringen (a has many association) which are broadcast yesterday. Phat!
install:
script/plugin install git://github.com/binarylogic/searchlogic.git
Runner up: Flag Shih Tzu
I have recently started using a new plugin. This one is pretty awesome as well, it might make it to the top of my list in a little while.
github
Flag Shih Tzu promises to get rid of all boolean flags used in my models. Especially handy for a User class, with boolean fields like admin?, confirmed? and Page classes with boolean fields published?, visible?, online? etcetera. Each separate boolean is stored in an integer bit field. Huge advantage is that the integer column can be indexed. Flag Shih Tzu also introduces handy named scopes for every flag.
Install with ./script/plugin install git://github.com/xing/flag_shih_tzu.git
you should check out also MetaTags plugin
http://github.com/kpumuk/meta-tags
[...] once in a while I post about cool plugins essential for Rails development, on the off chance you haven’t [...]