Wolfmans Howlings

A programmers Blog about Programming solutions and a few other issues

Developing a social networking site part 3 - tag cloud

Posted by Jim Morris on Sat Jun 23 14:02:49 -0700 2007

This is a simple one.

I use the excellent acts_as_taggable plugin, and I wanted to have a tag cloud like everyone does.

Of course I have different Models that can be tagged, and I want to keep everything DRY, so I created a helper and put the following in the application_helper.rb file

This allows me to have multiple tag clouds for the different models, see snowdogsr.us on the left bar at the bottom.

The font is bigger for the more popular tags, and you can click on any tag to get a listing of all matching articles.

I use RESTful routing so I added this to routes.rb

  map.resources :places, :collection => { :tagged => :get }

which creates a named route tagged_places_path which returns an index with the places tagged with the tag that was clicked.

The places_controller method looks like this...

Posted in Rails  |  Tags rails,tagcloud,acts_as_taggable  |  no comments

Comments

(leave email »)