Monday, July 20, 2009

Evaluation Report

My final summary and elevator pitch is contained at Elevator Pitch 2.

The transcript of the report is as follows:

As our journey investigating the issues surrounding Business Application development draws to a close it is time to reflect on what we have seen and experienced.

The topic series and related exercises has delved briefly into areas such as e-commerce, distributed systems, database and application servers, system security, system design and mobile computing.

The workshop series required the development of an Online Taxi Booking System using the Ruby on Rails framework as a design platform. It introduced the MVC design pattern and DRY principle and pushed the convention over configuration mantra espoused by the Ruby community. At times major frustration and gnashing of teeth ensued, but it all came good in the end.

These topics and workshop series have all added a little to the total understanding required to develop a Business Application in today’s rapidly changing online environment.

Progress along this journey has been detailed in our blog which has proved both useful and enlightening.

Sunday, July 19, 2009

Workshop 7: End of the Line (Part 2)

Well it appears that I was wrong. I have managed to produce an application that integrates booking a cab with an authentication mechanism. However even though I have successfully melded these 2 attributes together the sum of the parts still does not make an appropriate production application.

In order for this application to be production ready a large number of enhancements would need to be developed. This would include the following:

  • save bookings to database
  • allow retrieval of previous bookings so user can review booking history
  • allow for payments
  • have comprehensive test suite
  • etc

Deployment

According to (Hartl, chapter 17) Mongrel is suitable to use as a webserver for Production use with a ROR application. Currently, there are only two things that everyone seems to agree on: Use Mongrel as the Rails application server, and deploy to some flavor of Unix (most commonly Linux). The rest is up to you. One option is to use a shared host. Because of the explosive growth of Rails, there are now many shared host options, and a web search for "Rails shared host" provides a cornucopia of possibilities. If you're deploying to your own server, they recommend running Apache in front of a single Mongrel process to start.

After locating the server, to deploy you need to do the following:
  1. Create the production database
  2. specify the production database details in the database.yml file
  3. migrate the application to production
    rake db:migrate RAILS_ENV=production

(Hartl, ch17) recommends the following to set up a production Rails application:

  • Linux/Apache/Mongrel for deployment
  • Caching mod_proxy_balance and shared nothing and for scaling
  • Subversion or darcs for version control
  • Capistrano for automated deployment and rollback

References
Hartl, M & Prochazka, A (2008). RailsSpace: Building a Social Networking Website with Ruby on Rails, Pearson Education

Workshop 6/7: Application Success

The following screenshots define the application that I developed today after reading RailsSpace and developing as I read:
The home page:

The about page:

The help page:

The login page:

The user hub once logged in:

Choosing to book a taxi:

The user selections from the booking screen. This is where more work would need to be done in a production environment or working application. A booking record would need to be written at this point and the user notified of thir booking number.

If the user selects Boioking History from the hub screen then all booking for the current user should be displayed.

If the user selects the logout option then they get sent here:

The following shows the user registration screen:

Here we see that we have form validation enabled:

This shows a succesfully registered user, has the same effect as a user logging in:

Workshop 6/7: Integrating RailsSpace with OTBS

I have got the RailsSpace application to the point where it should be really easy to integrate what i had done previously with the OTBS.With that in mind
  1. I created a vehicle controller
    ruby script/generate controller Vehicle cabtype bookcab
  2. modified the bookcab.html.erb to look like we did in Workshop 4
  3. Changed the link in the application.html.erb file to point to the vehicle bookcab form


    Unfortunately when you choose the link I get the following error message:

    I would love to continue investigating the issue, but unfortunately I have now developed a visual migraine, and looking at the computer screen is akin to looking at a kalaidescope.
  4. Pregnant pause for 2 hours .....

  5. Well I have my application working. Yee haa! The comment from Karen helped in the end. The error about the unknown route was purely because I had not restarted the server after creating the vehicle controller.
  6. I have managed to integrate the RailsSpace application with the OTBS application we have been developing. See my next post for application details.

Workshop 6/7: Developing RailsSpace

The following are the steps I have taken to develop the RailsSpace application:
  1. ruby script/generate controller Site index about help
  2. Here is where we learn how do undo things.
    ruby script/destroy controller
  3. Change the root mapping in the routes.rb file
    map.connect '', :controller => "site"
  4. Then to ensure that the default routing works we need to remove the public/index.html page.
  5. Modify the pages defined when we created the Site controller (index, about and help)
  6. Modify layouts.
  7. Add navigation and the site looks like:

  8. Add css and the site now looks like

  9. Well now we want to create a user so we need a database. I have create a mysql database called railsspace.
  10. Generate the user model
    ruby script/generate model User
  11. create the user in the database
    rake db:migrate
  12. learn here that we can roll back the database migration by using the command;
    rake db:migrate VERSION=0
  13. Add validation to the user model.
  14. Testing the validation gives the following output
  15. Add magic columns to the model
    ruby script/generate migration AddUserTimestamps
  16. Add user controller to enable us to register users
    ruby script/generate controller User index register
  17. At this point I got a hosting error within APTANA studio that says I couldnt have 2 application using the same host. I have gotten this error before and the only solution I could find was to close and restart APTANA. This worked.
  18. So I now have the following nicely rendered registration page:
  19. Add debugging info so that we can debug easily. Gee I wish I had seen this before. Very nice!!
  20. Continuing on we deal with what happens if a user registers successfully.The following screenshot shows this taking place:
  21. Add the link to the registration page in the application.html.erb file
  22. Add a helper function to reduce ugly code and then review documentation
    rake doc:app
    and then view doc/app/index.html
  23. Clean up the database
    rake db:migrate VERSION=0
    This will clean the database

    rake db:migrate
    This will rebuild the database

  24. I would love to investigate the testing functionality within ROR but due to time constraints I am going to bypass this section. (Here is hoping that this decision doesnt come back to bite me.)
  25. I am now back to where I started the RailsSpace review earlier today. ie I have now created the session
  26. Modify the user_controller so that registered users are automatically logged in.
  27. Change the application.html so that if we are developing we can see what the session variable contains as well. Add some javascript to display individual debug options seperately as required.
  28. Lets add a login template and link the main application screen accordingly.
  29. We can now add a logout page as well and modify the code so that the appropriate menu items appear dependent upon the logged in condition.
  30. Now lets create a protected page
    I added the code "the stupid way" as the book says inside the controller and verified that it worked.
  31. Add nice URL forwarding to protected pages, once user is authorised, by utilising the properties of the request.request.uri
  32. At this point we are all about looking at code refactoring

Workshop 6/7: Reading RailsSpace

Well I think that I made another mistake in developing my application. I didnt read the railsspace text sufficiently. I relied on the learningrails podcats/screencast series to develop the login module. As you will have noticed reading my blog this was in no way successful.

I am currently reading section 6 of RailSpace and it looks like it shows what i should have done to get the login process to work. It is actually debateable at this point as to what i would need to do to get the OTBS to work and utilise the login functionality correctly. It could be that if I implement the session logging capabilities in Section 6 of RailsSpace, that i may actually get a functioning application. But on the other hand, I may find that I am being led up yet another garden path.

In order to investigate whether RailsSpace would in fact revive my application I would be inclined to once again rebuild my OTBS application from the ground up. This goes entirely against the principles espoused by the rails community of DRY or dont repeat yourself (did I actually just break that rule by spelling out the DRY definition?). But considering I am between a rock and a hard place in terms of a functioning application, I feel that this is sctually the best method.

Concurrently with starting with a completely fresh application, I would implement a source code control systems to ensure that I was able to backtrack if and when the need arose.

Well I have just created a new rails application, to see if the logging mechanism within RailsSpace will actually work for me. Following on from the steps is section 6:

  1. Run rake db:sessions:create
  2. This was successful
  3. In config/environment.rb, uncomment the line:config.action_controller.session_store = :active_record_store
  4. Well here was my first problem. There was no such line in the file. So I copied the line from RailsSpace into the file.
  5. Run rake db:migrate
  6. Well this bit worked fine.
  7. Its at this point that I realise that we need to go back to the beginning of the book and actually build an application, because there is currently nothing in this one. So its back to the start of Chapter 2.

Workshop 6/7: My final application

Below are screenshots of my application as it stands:
  1. This shows the main page when you first start the application.
  2. If I click on Log Out the following screen appears:

    This would seem to imply that the user has been logged out. Howver if I simply click on Book Cab

  3. This is the screen that display when the user selects Book Cab. Irrespective of the user being logged in or not.


  4. This is the screen I get if I try to login from the login screen without a valid user being specified.
    This actually implies to me that the session management is working correctly, but I am not getting the expected results throughout the application.