Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Build a Wiki System with Rails

Learn how to build a simple, file-based Wiki system using the Ruby on Rails web application framework. You won't believe how easy it is.


advertisement
he Ruby language and the Ruby on Rails (Rails for short) web application framework have created a lot of buzz in the software programming industry and for good reason. While Ruby has been around for more than a decade, the Rails framework is relatively new but it is becoming a darling of many programmers who are tired of the overly complicated world of web frameworks.

This article demonstrates just how easy it is to write a simple Wiki application using Ruby and Rails together. While Rails is used mostly to build database applications, this article goes the file-based persistence route because I personally like using Wiki systems that are file based and coincidentally they are easy to set up. In addition, very few resources on the web discuss developing non-database applications using Rails. Still, switching to a database using the Rails database support should be relatively painless if you choose to go that route.

What You Need
You'll need a working knowledge of the Ruby language and the Rails framework to follow this article. If you are new to either of these, check out the following, previously published DevX articles:



Furthermore, the Related Resources section in the left column provides some links for additional information.

In order to build and run the example wiki, you will need to have three core pieces of software installed:
  • Ruby interpreter
  • RubyGems packaging system
  • Rails framework

In addition, you will need a Ruby gem named RedCloth as the text markup engine. The following is a list of locations for all this software, along with the versions used for this article (note: this software must be installed in the order shown):

  1. Ruby interpreter (I used version 1.8.5.)
  2. RubyGems packaging system (I used version 0.9.2.)
  3. Gems:
Assuming you have everything installed, you can test your configuration using the following commands:
  1. ruby --help
  2. gem --help (or better yet, gem list --local)
  3. rails --help

Features of the Wiki System
Before jumping into the code, let's review some features that the Wiki system, I have named RailsWiki, needs to provide. Wiki systems provide simple ways of adding, editing, and removing content using the web. So, the RailsWiki naturally should enable the user to do at least the following:

  • Create a new Wiki document.
  • Edit an existing Wiki document, with the ability to use a text markup language for formatting the content.
  • View (open) an existing Wiki document.
  • Print an existing Wiki document.
  • Delete an existing Wiki document.
  • List all previously created Wiki documents (for viewing or deleting purposes).

Next, let's review UI mockups that implement these high-level feature requests, also known as user stories. Figure 1, Figure 2, Figure 3, and Figure 4 show screenshots for a wiki's home page, view feature, edit feature, and print feature, respectively. These figures reflect most of the features you need to implement RailsWiki.


Figure 1. Wiki Home Page
 
Figure 2. View Wiki


Figure 3. Edit Wiki
 
Figure 4. Print Wiki



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap