Home arrow Ruby-on-Rails arrow Forum Implementation
RUBY-ON-RAILS

Forum Implementation


Setting up a forum is a great way to keep your customers interested and get feedback on what you're doing. This article, the first part of a four-part series, will show you how to set one up for an online bookstore using Ruby on Rails. It is excerpted from chapter six of the book Practical Rails Projects, written by Eldon Alameda (Apress; ISBN: 1590597818).

Author Info:
By: Apress Publishing
Rating: 5 stars5 stars5 stars5 stars5 stars / 3
May 20, 2010
TABLE OF CONTENTS:
  1. · Forum Implementation
  2. · Using the Threaded Forum Plugin
  3. · Setting Up the Forum
  4. · Modifying the Model

print this article
SEARCH DEVARTICLES

Forum Implementation
(Page 1 of 4 )

In this chapter, we will show you how to implement a forum that can be used by Emporium's customers to discuss book-related topics and provide feedback to George. Gathering feedback from customers is an important part of an e-commerce site, as it allows you to adapt and improve your service. For example, before implementing a new feature, you could post a message to the forum, asking your customers if they would use the feature. If the answer is no, you will save both money and time. Other uses for a forum include allowing customers to post bug reports and review books, for example.

Implementing a forum can be time-consuming. To save us some time, and save George some money, we will use the acts_as_threaded plugin as the basis for the forum implementation. While implementing the forum, we will also show you how to use view helpers. View helpers are a built-in feature of Rails that allow you to keep your views clean from excessive Ruby code. As usual, we will use TDD while implementing the forum, to ensure that the forum is properly tested and working according to the requirements. And as in previous chapters, we will use integration testing. In this case, we will simulate multiple users accessing the forum and posting to the forum at the same time.

Getting the Forum Requirements

We start the new day in our humble cubicle, by arranging a meeting with George to discuss the requirements for the feedback forum. George tells us that he is excited about the new possibilities the forum will offer. He yells, "It has to be simple to use. I must also be able to use the forum!" We show him a sketch of the user interface as we envision it. The create post page has three fields: name, subject, and body. George jokes, "Looks like I will be able to use that." We tell him this is as simple as it gets, and that each discussion in the forum (also referred to as a thread) starts from a root post. Replies to the root post are shown in a threaded fashion, so that it is easy to follow the discussion. We write down the first user stories, View Forum and Post to Forum.

Next, we show George a sketch of the View Post user story. He says, "You guys are professionals. I haven't seen the forum yet, but I can already feel that it will be something special!" We assure him that the forum will be simple and easy to use, and then continue by writing down the View Post user story.

George informs us that we have to end the meeting early. He has just received news from Jill (Emporium's best customer) that the Emporium website is down again. He has to make an emergency call to his IT department, which happens to be his nephew. Before he leaves, we show him a sketch of the Reply to Post user story. He again praises our fine sketches and runs off towards the basement, mumbling, "I really hope that darn rat hasn't put its head through the server's processor fan again. It would be the third time this month." We try not to pay any attention to what he just said and write down the Reply to Post user story.

With George in the basement, we can start the implementation of the forum. Here are the user stories for this sprint:

  1. View forum: Users should be able to list all posts in the forum. Posts belonging to the same discussion should be shown in a threaded fashion, and the list should be sorted, with the most recent posts shown first.
  2. Post to forum: Users should be able to start a new discussion in the forum by entering their name, a subject, and the body text of the post. 
     
  3. View post: Users that are viewing the forum should be able to click on a post and view the details. 
     
  4. Reply to post: A customer views a forum post and decides to reply to the post by clicking the reply link. The user enters his name, the subject, and reply message, and then clicks the reply button.

We'll get started by installing the acts_as_threaded plugin.


blog comments powered by Disqus
RUBY-ON-RAILS ARTICLES

- Ruby-on-Rails Faces Second Security Flaw in ...
- Ruby 2.0 Prepped for February 2013 Release
- Why LinkedIn Switched from Ruby on Rails
- Adding Style with Action Pack
- Handling HTML in Templates with Action Pack
- Filters, Controllers and Helpers in Action P...
- Action Pack and Controller Filters
- Action Pack Categories and Events
- Logging Out, Events and Templates with Actio...
- Action Pack Sessions and Architecture
- More on Action Pack Partial Templates
- Action Pack Partial Templates
- Displaying Error Messages with the Action Pa...
- Action Pack Request Parameters
- Creating an Action Pack Registration Form

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials