Showing posts with label Ruby on Rails. Show all posts
Showing posts with label Ruby on Rails. Show all posts

Thursday, February 15, 2007

Database Migrations for Agile Web Development

I love the concept of migrations found in Ruby on Rails. It allows you to use an agile methodology when developing web applications. You do not have to make a the full database design first before starting to develop your web application, you can start with a partial database design, make a working application then gradually evolve it in an easy way by adding more and more functionality till it reaches the full functionality you need.

The key here is that database migrations in Ruby on Rails make very easy to go back and forth between more or less functionality in the system you are building. I really hope that PHP would have some similar easy way that supports migrations. That way going truly agile with PHP would be possible as is the case with Ruby on Rail.

Thursday, December 28, 2006

RadRails Tutorial

If you've already installed and configured RadRails, here is what appears to be a good RadRails tutorial that goes beyond the fast and simple basics.

RadRails Demo Video

If you are new to RadRails, the popular Ruby on Rails IDE, have a look at this RadRails demo video to get familiar with some of the things it can do and how it does them.

Tuesday, December 26, 2006

Integrating RadRails into InstantRails

After downloading and installing RadRails, I was clueless about how to use it with InstantRails. I tried to use RadRails but failed completely. This made me leave RadRails and confine myself to using InstantRails alone from the command line console and the rudimentary file editor that comes with it.

Hearing about how convinient RadRails is, I thought of downloading the Ruby on Rails stack one by one by myself and installing it, first Ruby, then rails and finally downloading and installing MySQL then configuring them all and running them. But that sounded like a headache, after all InstantRails was doing all this for me in a single step.

I then, by accident, came across this clear and simple description of how to configure RadRails to work with InstantRails! Mission accomplished.

Installing ActiveRBAC

I have downloaded and uncompressed InstantRails on my Windows XP system. In order to perform user authentication in my web application, I attempted to install the ActiveRBAC library for Ruby on Rails. Steps for installing ActiveRBAC are detailed in the excellent ActiveRBAC tutorial. However, to further take confusion away from installation steps, I will outline here the final steps I have come up with after some trial, error, failure then success on my side in installing ActiveRBAC on my Windows system.

  1. Start InstantRails.
  2. Open a Ruby console window.
  3. cd your_app_name.
  4. ruby script/plugin discover.
  5. Reply by no to all questions, except the two questions for http://svn.rails-engines.org/ and https://activerbac.turingstudio.com/.
  6. ruby script/plugin install engines.
  7. ruby script/plugin install active_rbac.

Congrats, you're done!

Monday, December 25, 2006

RadRails - IDE for Ruby on Rails

RadRails is the leading IDE for Ruby on Rails. RadRails is a far cry from FreeRIDE, the popular Ruby IDE. RadRails is way better. RadRails is based on the IBM-backed open source Eclipse IDE. RadRails is basically a plugin for Eclipse. RadRails is built on RDT, an Eclipse plugin for Ruby, and JRuby, a pure Java implementation of Ruby to work with Eclipse. Go ahead and download RadRAils and experience its magic.

Sunday, December 24, 2006

User Authenticaiton in Ruby on Rails

Unlike in Django, the popular Python web application framework, Rails, again the popular Ruby web application framework, does not offer user authentication out of the box. If you want to do user authentication with Rails, you must use some plugin or write the authentication part of the web application from scratch. There are a number of ways to do authentication in Ruby on Rails. The salted hash loging generator is one popular method to do user authentication in Rails. Another method is the ActiveRBAC. RBAC stands for: Role Based Access Control. The nice thing about ActiveBRAC is that it offers more features the most important of which is allowing users to access parts of the web application based on roles. To get started, try your hands with this well-written ActiveRBAC tutorial.

Saturday, December 23, 2006

Ruby on Rails Forum

Get more familiar with Ruby on Rails and have your Rails questions answered at the Ruby on Rails Forum.

Friday, December 22, 2006

Ruby Developers in Egypt?

I came across this interesting site today, it's called Working with Rails. It is a community web site that allows Ruby on Rails developers to add their names and other info about themselves. I found 6 Ruby on Rails developers listed under the Egypt section of the site. I added myself, so now there are 7 Ruby on Rails developers from Egypt listed at Working with Rails. I hope this number increases many folds as time passes. I'm planning to offer a brief free Ruby on Rails crash-course at Resala, Masr El Gedida branch God willing.

Thursday, December 21, 2006

Steps in Creating a Rails Application

For those new to Rails, here is a proposed sequence of steps to follow in order to make a Ruby on Rails application:

  1. Use the rails command to generate a skeleton for your web application.
  2. Create a database and its tables using MySQL. Make sure to follow Rails conventions in naming tables and table columns.
  3. Use the scaffold generator to automatically create each model and its controller and views.
  4. Manually code relationships between tables into model files.

You can now go ahead and view your web application in the browser after starting the web server.

You can start shaping up your web application from here. Go back to the controllers and views, make needed modifications then go back and view your application in the browser. Keep modifying the application files till your web application is complete and is shaped like what you have in mind.

The above sequence is merely a proposed sequence. It is specially suitable for new comers to Ruby on Rails. Sure there are alternative paths. For instance, one can start by creating an empty database, and use Ruby on Rails migrations to create the tables. One can also go about writing controllers and views by hand without first using the scaffolding features of Rails.

If you would like to use migrations rather than creating the database tables directly with MySQL, then you can follow this alternative approach:

  1. Command line prompt, rails_apps folder: rails appname
  2. MySQL command line console: create database appname_development;
  3. Generate a migration after going to the appname folder: ruby script/generate migration add_tables
  4. Edit 001_add_tables.rb file to define database tables.
  5. rake migrate
  6. For each model (~table): ruby script/generate ModelName
  7. Define relationships between database tables inside model files (appname/app/models/ModelName)
  8. ruby script/server
  9. Open your browser at: http://127.0.0.1:3000/ModelName+'s'

Wednesday, December 20, 2006

Migrations in Ruby on Rails

When Ruby on Rails was first released you had to first create a database and all its tables by yourself. If you were using MySQL for instance, you could have created the database and its tables via the command line console or via PHPMyAdmin for instance. You had to do all this outside of Rails then go to Rails in order to start developing your web application.

With the introduction of migrations in Ruby on Rails, now all you have to do is create an empty database without even creating any tables in it. Then you go into Rails and write migrations. Those migrations take care of creating the database tables for you. The really interesting and useful thing about migrations is that you can expand your database by adding more tables or more columns to existing tables in an incremental way. The application would still run smoothly. Most importantly, you can role back to previous states of the database also using migrations. For instance let's say that after you had a database containing a table with 4 columns you made a migration to add a 5th column to that table. You can easily role back to the previous state of the database when it had only 4 columns by using migrations in Ruby on Rails. With complex database structures that have many tables and many columns built in an incremental way, the migration feature of Rails makes it very convenient to go back and forth between different stages of the database without worrying about spoiling it.

Monday, November 27, 2006

Rails and Clean URLs

One cool feature about Ruby on Rails is that clean URLs is something that comes natural. Rails uses clean URLs by default. I love this. This is because I have suffered a lot with Drupal trying to make it use clean URLs. I also found it needed some work with PHP trying to make it use clean URLs too.

The W3C web site uses clean URLs in all its web pages. One interesting article in the W3C about clean URLs talks about this. The article though comes under the name Cool URIs.

Thursday, November 16, 2006

Ruby on Rails Gaining Popularity

Ruby on Rails is gaining popularity as indicated by Google Trends.

Monday, October 16, 2006

Ruby on Rails

Today I managed at last to make Ruby on Rails work on my website hosted at BlueHost. Ruby on Rails is a web application framework that lets you create web applications in a more neat and much faster way than using PHP. Here is a simple introduction to what Ruby on Rails is all about.