Computers, Open-source, Personal, Ruby, Software, Web

Adventures with Rails: Part Trois

The last few days have been particularly productive with the L****** management application I have been working on. In particular, I now have full user authentication working per method in the controllers. Authentication is done via several tables mapping users (username), roles (role), and components (components), via a permissions table (user_id, role_id, component_id). I figured with would be a daunting task to represent these relationships between the tables inside the models, but this was not the case thanks to ActiveRecord’s convention over configuration.

Inside the users model, I can make represent the relationships easily like

has_many :permissions
has_many :roles, :through => :permissions
has_many :components, :through => :permissions

Then, I can do something like:

User.find(session[:user_id]).permissions(:all)

In the above example, the user_id column in the permissions table implicitly joins the permissions table with the user’s table.

Now for some images:

The new permissions manager now easily doles our permissions for users and components. Thanks to the ActiveRecord magic above, this form is entirely constructed with a few lines of code.

The dashboard controller attempts to pull a partial template named “dashboard” from each of the controller’s listed in the components table and display its options below. Also, each of the controller’s default actions point to this template, so everything remains DRY.

The new statistics controller will pull much information from the host, including all running processes, with a search area, and AJAX periodically updating the list of processes.

One of the easier things to happen in this project has been the inclusion of Google Charts. Its API is URL driven, but as if that was too hard, Ruby has a few projects that act as wrappers for the API. I can simply run a query, and pass the results to the wrapper, and have this pretty graph draw automatically. Nice!

A very productive week I think. Now its getting close to being something I can release.

Advertisements

2 thoughts on “Adventures with Rails: Part Trois

  1. This project is really moving along quickly. I can’t wait to start actually have SWAN be used on campus so we can start using this ;-). The google charts stuff is so cool though. I couldn’t believe how easy it was to get some fairly complex graphs with just a simple call to the wrapper.

    Like

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s