Home > Others, Webmasters Resources > Ruby on Rails Can Help You

Ruby on Rails Can Help You

Ruby on Rails, an open source web development framework, has revolutionized the way we create web applications. By giving developers the necessarily tools and components needed to build powerful apps in an intuitive development environment, RoR makes development more efficient and less troublesome.

Rapid Development and Prototypes

 

In this article, we discuss some of the ways Ruby on Rails can help you in rapidly building fully-featured web-based applications.

1. Rapid Development and Prototypes

 Rapid Development and Prototypes

Issues caused by old techniques

When developing a website for a client, I want to concentrate on the clients needs i.e. the domain problem at hand. I don’t want to start thinking about setting up mountains of configuration files. Having to deal with such annoyances just delays what you are actually trying to achieve i.e. create a website which is specific to your clients domain. With conventional web development techniques, this issue can slow down the development process.

How Rails can help

Ruby on Rails uses a concept called Convention over Configuration which makes you follow conventions while you’re coding, leaving you with little configuration to do. For instance, if you created a model class called “Post” the corresponding database table will be called “posts” and the controller class will be called “PostsController”.
Further to this, Rails has a nice feature called scaffolding. Scaffolding allows you to create useful prototypes for clients in super fast times. However, a word of warning, it is deemed bad practice to use scaffolding code for actually building the final draft of a web application.

2. Structured Code and Neat Markup

Structured Code and Neat Markup

Issues caused by old techniques

The main problem here, is separating the view markup from the business logic. A lot of old ASP and PHP web application have the business logic code scattered throughout the HTML. This makes life very difficult for, not only the programmer maintaining the code but the designer who is trying to find the markup. Needless to say, things were very unstructured in the web development days of yore.

How Rails can Help

As with many web frameworks, Rails uses the MVC compound design pattern to solve this problem. MVC (model-view-controller) splits the business logic into a “Model” layer and the view logic into a “View” layer. The “Controller” interacts with the Model and passes the required data onto the View. A full HTTP request cycle can be simplified into the following steps:

  1. The user sends a HTTP request by typing the required URL into the browser. This request is routed to a specific method in the controller.
  2. The method, being executed on the controller, interacts with the required model, which will usually retrieve some data from the database.
  3. The controller then passes control to the view, which specifies which HTML elements should be rendered and makes use of any data passed from the controller.
  4. The prepared HTML response is then passed back to the users browser.

So, what does MVC do for you? You will have clean, structured code, which is easily maintainable and very flexible. Enough said.

3. Interchangeable Databases

Interchangeable Databases

Issues caused by old techniques

I’m sure plenty of you have been there; Just created a lovely new, fully working, website using MySQL as the DBMS then, out of the blue, the client says "Oh Yeah, we don’t use MySQL, we use…". What do you do? Panic about all those embedded SQL query strings scattered throughout your code?

How Rails can Help

With Ruby on Rails this is not a problem, why? Well, Rails is database independent, meaning you can simply make a few configuration changes and hey presto, you’re now using Microsoft SQL or Oracle or SQLite (I could go on).

Further to this, Rails implements a design pattern called ActiveRecord to achieve Object Relational mapping (ORM). What the hell does that mean!?, I hear you say. This basically means that classes in your code can map directly to tables in your database. You can even define relationships between those objects in your classes.

ORM makes it simple to query the database without using database dependent SQL query strings, contributing to database agnosticism.

4. Database Schema Control

 Future past sign post

Issues caused by old Techniques

When working in a team of more than five, it can become hard to keep track of what changes are being made to the database. For example, someone could make a change to the database, removing a field from a table. Meanwhile, you could be writing code which expects that field to exist, simply because you are using an old revision of the database schema.

Categories: Others, Webmasters Resources Tags:
  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.