Blog Post RSS ?

Blogs » Ruby on Rails » Building blocks for a CMS
 

Building blocks for a CMS

by Tim Lucas

Though there’s been a few attempts at creating high-level, pluggable components in Rails, nothing has really seemed to catch on. There’s Rails engines and some full-blown CMS packages, but there’s still a tendency to built things from the ground up. Why is this?

I’ll list a few low-level tools that you can integrate into any project, that don’t mess with Rails internals and are dead-easy to set up and use.

  • acts_as_tree or acts_as_nested_set

    Built into Rails, these will give you a tree model for any model objects. Sprinkle on LiveTree for a Javascript-based UI.

  • acts_as_versioned

    Store previous copies of Pages, Assets or any danged model that you please.

  • acts_as_versioned_association

    Building on top of acts_as_versioned, this provides versioning support for your associations, so if you had a Page that had associated ImageAssets you could retrieve an exact copy of your page along with the associated image assets at that point in time.

  • Polymorphic associations

    Built into Rails 1.1, polymorphic associations allow you to associate a model with any other type of model through a polymorphic join association. This means you could tack a Comment onto any of your model objects, like in the following example:

    
    class Comment < ActiveRecord::Base
      belongs_to :commentable, :polymorphic => true
    end
    

    Adding comment support to a model is simply a matter of inserting a has_many one-liner:

    
    class Post < ActiveRecord::Base
      has_many :comments, :as => :commentable
    end
    
  • acts_as_attachment

    Provides both file and DB-based upload storage, as well has ImageMagick support for auto-resizing of images. If this isn’t flexible enough there’s the more image-manipulation-based ImageMagick for Rails plugin.

What other building blocks have you used when adding typically CMS-like features to your Rails application?

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Ping.fm
  • Twitthis

Related posts:

  1. FullCodePress Update: CodeBlacks Bet On Beta CMS The New Zealand team have made an interesting choice of...
  2. Building on a Closed Platform? Tread Carefully Building a business on the back of a closed development...
  3. Famous Rails Screencast Gets an Update When Ruby on Rails was first introduced, nothing helped put...

This post has 9 responses so far

Sponsored Links

SitePoint Marketplace

Buy and sell Websites, templates, domain names, hosting, graphics and more.

Follow SitePoint on...