HomeRamblings  ⁄  activerecord


One ActiveRecord Model Acting as a List and Tree

Occasionally, Rails can appear to make your life extremely easy while silently throwing you a curve-ball. I needed a model that required a hierarchy while also preserving order of the records. Although fairly straightforward to set up and start immediately using, there are a couple of "gotchas" to watch out for and this article covers those pitfalls and shows how to apply the cool new "dirty attributes" feature in ActiveRecord. ## The Problem I am working on a content management system (CMS) where I want the pages to have a hierarchical structure that turns into a menu with sub-menus. The content manager needs to also be able to order these pages so that the menu structure renders in the desired order. ## The Solution Two plugins jumped to mind almost immediately: **acts_as_tree** and **acts_as_list**. The tree plugin will manage the… read more

Ramaze and ActiveRecord

Thanks to the great folks on IRC over at Freenode#ramaze, I was able to not only get Ramaze working with Erubis and Activerecord for a pseudo apples to apples comparison of Rails vs. Ramaze performance benching, but I was also able to get Apache 2.2.9 talking to Passenger to Ramaze. This quick post will take you through the basics. ## Environment This post will guide you through setting up the following environment on Ubuntu Intrepid (8.10): * [Apache 2.2.9][1] * [Passenger 2.0.6][2] * [ActiveRecord 2.2.2][3] * [Ramaze 2009.01][4] * [Erubis 2.6.2][5] * [MySql 5.0.67 (assumed installed)][6] To get started: ~~~ bash sudo apt-get install apache2 passenger sudo passenger-install-apache2-module ~~~ Install the Rack, Ramaze, Activerecord, and Erubis gems ~~~ bash sudo gem install rack, ramaze, activerecord, erubis ~~~ ## Establishing Project Now create your first ramaze project with: ~~~ bash ramaze… read more