Journal of a Geek

Mission Complete?

leave a comment »

I have finally finished my content management system for the school newspaper…kinda. I was setting up the mongrel server for launch of the website, when my boss comes in to tell me we are giving control of all our server’s back to the school. This means no scripting languages of any kind.

At first I was a bit upset. I had spent a year learning ruby/rails and developing this CMS. My first idea was to simply take the style sheet and apply it to the current site we have. I was dreading this not only because I was going to have to do more CSS work which I hate, but the main reason I had made the CMS, ease of input, would be lost. Thanks to the Rails caching system and a friend (thanks Dane), I came up with a solution that saves the general purpose of the content management system, and gives the website the new look.

For those of you new to Rails, I’ll give a quick explanation of how the caching system works. When Rails creates a page from the view, it is actually generating a hmtl file. So what the caching system does is create a copy of the html file the first time the page is generated. The next time someone request the page the html page that was saved is served instead of the one that needs to be generated. This decreases the load on the server. (Note: Rails can be told to save only specific parts of the page, but that is a bit more detailed than what I used here.)

So if you add the following code to a controller it will cache the pages for you when the Rails application is put into production mode:

caches_page :show, :list

This code tells Rails to cache the show and list pages the first time they are visited. The other part of this is sweeper code which deletes cached pages for you, so that when you change them they get properly updated. I have yet to add that, but will post it once I have completed it.

So my solution was basically consisted of running the website on my local machine, entering the data, then uploading the cached files to the server. I am still kind of sad that I lost my comment, search, and tagging features, but at least I got some use out of it.


Written by Ryan Farnell

September 20, 2006 at 3:18 pm

Posted in Web Development

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: