- ruby script/generate controller Site index about help
- Here is where we learn how do undo things.
ruby script/destroy controller - Change the root mapping in the routes.rb file
map.connect '', :controller => "site" - Then to ensure that the default routing works we need to remove the public/index.html page.
- Modify the pages defined when we created the Site controller (index, about and help)
- Modify layouts.
- Add navigation and the site looks like:
- Add css and the site now looks like
- Well now we want to create a user so we need a database. I have create a mysql database called railsspace.
- Generate the user model
ruby script/generate model User - create the user in the database
rake db:migrate - learn here that we can roll back the database migration by using the command;
rake db:migrate VERSION=0 - Add validation to the user model.
- Testing the validation gives the following output
- Add magic columns to the model
ruby script/generate migration AddUserTimestamps - Add user controller to enable us to register users
ruby script/generate controller User index register 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. - So I now have the following nicely rendered registration page:
- Add debugging info so that we can debug easily. Gee I wish I had seen this before. Very nice!!
- Continuing on we deal with what happens if a user registers successfully.The following screenshot shows this taking place:
- Add the link to the registration page in the application.html.erb file
- Add a helper function to reduce ugly code and then review documentation
rake doc:app
and then view doc/app/index.html - Clean up the database
rake db:migrate VERSION=0This will clean the database
rake db:migrateThis will rebuild the database
- I am now back to where I started the RailsSpace review earlier today. ie I have now created the session
- Modify the user_controller so that registered users are automatically logged in.
- 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.
- Lets add a login template and link the main application screen accordingly.
- 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.
- 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. - Add nice URL forwarding to protected pages, once user is authorised, by utilising the properties of the request.request.uri
- At this point we are all about looking at code refactoring
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.)
No comments:
Post a Comment