Generate Entity-Relationship diagrams from Rails ActiveModels


Hey people! Documenting your code is really crucial for projects regardless of the size of the project. There are a lot of stuff that must be documented in a project. You have various tools to generate documentation for your code. I am going to show you a tool, a gem, that allows you to document your database models. When I was doing my Pacman (github.com/steverob/student-marks) I used an online uml tool called “dbdsgnr” to document my database. But I had to make many chances to my database schema and updating the Entity Relationship diagram I had on that website was getting tedious. At one point I dropped the whole idea of maintaining that piece of documentation. When I completed my project (pending testing), I wanted to document my database and I was searching for a tool that would document my rails project by reading the ActiveRecord models that I have. That was when I found this really cool gem called ‘rails-erd’.

This gem is maintained at github/voormedia/rails-rd and the project website is rails-erd.rubyforge.org. Installation of this gem is pretty easy. It depends upon a graphics tool called Graphviz.

You can install graphviz on Ubuntu using the command,

sudo apt-get install graphviz

Now add ‘rails-erd’ to your project’s Gemfile under the development group. So it would look like,
group :development do
gem "rails-erd"
end

Now run ‘bundle install’. This will enable your project to use the rails-erd gem.

We have installed the gem and its dependency. All we have to do now is to run a simple rake task to generate the ERD. The command is,

rake erd

This will generate “ERD.pdf” file in the application root. Neat huh? The best thing about this is that you can customize the way the output is generated by passing in many options. The various customizations are clearly explained in the project’s website. But mostly you wouldn’t need much customization. And I can tell you, the output is quite awesome. The entities are spaced well and the overall alignment of the diagram is quite brilliant. It looks like as though someone had manually aligned the entire thing. Okay, you’ll know what I am saying when you see the output pdf that I got for my project. Here it is. Click the image to get a better view.

See? Its just awesome. For more information regarding the gem visit rails-erd.rubyforge.org.

Steve

Installing Ruby, Rails, MySQL and Apache on a fresh Ubuntu 12.04 installation


The first challenge I faced when I started using Ubuntu was moving my Wubi installation inside Windows to a separate partition. Thats when I understood how one should find his/her way around the problems they face using Linux. Linux has one of the biggest support base on the internet. You can find solutions to almost all problems you face in the web. The only thing you need to do is a simple and proper Google search and you’ll fix whatever problem you have in not time at all! But unfortunately many who are new to this whole idea find it really difficult using Linux. This is because they are completed immersed in and used to the way Windows works. And so whenever they face some problem in Linux, like a dependency issue, they call you or text you and ask you to fix their problems. Unlike in windows where you get generic error messages with an error code, Linux provides verbose details about the kind of error that has occurred. People must make use of this information to find solutions to their problems.

Okay enough said! When I started learning Ruby I wanted to install Ruby on my Ubuntu 11.10 installation. But I really didnt know that I already Ruby pre-installed! Not knowing this I started installing Ruby and I faced a lotta issues. I had no idea what was happening. Then I tried removing Ruby. Then after my failed attempts to remove Ruby completely I installed RVM. Then I installed a Ruby version via RVM. But then gems like rails etc just wouldn’t install. Me being a Linux beginner back then found it really irritating and annoying to the extent that I considered dumping the whole idea of learning Ruby. But the pure elegance of Ruby and the thirst to learn Rails made me keep pushing. Finally after two days I got Ruby and Rails working on my PC without re-installing Ubuntu :P. Since then I’ve made several Ruby and Rails installations on many computers. I faced a lotta issues, especially dependency problems when installing Ruby, Rails, MySQL etc. So I decided to write this post to tell those beginners out there, the stuff they would need to properly install Rails etc.
Continue reading

A handy tool for our college staff


Hello people!! Its been a really long while since I posted anything here. Its been a really good 6 or 7 months for me both academically and personally. Been through a lot of changes, learnt new stuff, decided on my main field of interest etc! Well… the main thing is, Im Back! Ive jumped over to the Ruby on Rails platform now. And I think I love this platform. Its a joy to write code in Ruby and extra joy to use the goodies provided by Rails.

I also have undertaken a project for my college to manage marks and attendance which is almost complete. I will write an exclusive post about that in coming days.

Ok. Before I begin this post I cant help mentioning how good Chelsea are performing this season! 😀 We’re on course for a Title win! 🙂

Ok okay… My college’s management is very demanding. When our university results come, the staff are required to get the results from the results websites, analyse the results and generate reports on the very same day which can be a really challenging and tiresome task given the large number of students in each batch.

I always wanted to help then out by giving them an easy way around this cumbersome job. Ive tried finding loopholes and vulnerabilities in the University Server but hit dead ends all the time. Finally I decided that the only way (atleast for me) to get the results was to parse the results from the website directly from the HTML page. I had this idea in mind but did not implement it until the results came for my 6th semester!

That night I was reading stuff when one of my friends texted me saying that the results have come. I opened the results website without any sorta excitement or expectations 😉 coz I already know that Anna University (the uni to which my college is affiliated to) is known for throwing big surprises. And they did not dissapoint! An average result once again (for me). Well I had to do something to divert my mind. So I thought of writing the app to download the results! 😀 And my word! It was a brilliant idea 🙂
Continue reading