Sunday, July 19, 2009

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

No comments:

Post a Comment