MarkUs Blog

MarkUs Developers Blog About Their Project

Tagging Backend

without comments

This blog post will discuss the decisions made surrounding the backend of the Tagging Project.

Database Schema

As this is the initial implementation of the Tagging feature, we strove to keep the schema changes as simple as possible.  MarkUs uses ActiveRecord as the M in MVC, and thus we had to create ActiveRecord migration files to implement changes.

We decided to create a Tags Model which contained the following explicitly declared pieces of information:

  1. name (string)
  2. description (string)
  3. user (string)

and an integer id that is implicitly declared.  Furthermore, we created a groupings_tags association to create a many to many association between groupings and tags.

That migration file explicitly associates and a tag id with a grouping id and adds a index of the two ids that must be unique.

An interesting thing with ActiveRecord migration files, and increased its ease of use, is that each migration file must specify the action being done(creating table, adding an attribute to a table etc) but also the action that must be done to rollback these changes.

In this case, the rollback operations for each files solely consisted of dropping each table(and removing the index for the grouping_tags association).  This made it quite easy to create and edit the schema in subsequent iterations.  Editing the schema file would consist of the rollback command, editing schema file, and re-migrating.


In editing the model files, we only had to create a tag.rb and modify the grouping.rb to reflect the new schema.


In creating the tag controllers, we had to split up the logic between a tags_controller.rb and a tags_helper.rb module.

The interesting between the tags_helper module and the tags_controller is that other controllers can include the module and directly call its method.  This is not the case for tags_controller; routes.rb needs to consulted to call its methods.

The methods in the tags_helper modules are used by controllers (e.g. tags, results) whereas methods in tags_controller are called from views.

For example, methods in the controller include index, edit, create, destroy.  The module has methods that do work with groupings and tags, which are needed by the results_controller.

Written by Nathan Chow

December 15th, 2014 at 1:31 am

Posted in Uncategorized

Leave a Reply