In the previous section I have showed a simple application with no overheads of validation or with no overhead of complicated style sheets. It was just a very basic book store application which will update the list of books with details entered into the database and we have choosen MySQL as our database application, and we also saw how the data been entered is shown in the updated list.
Well so said today I will teach you how to update a perticular record and then to delete the same as well
I have added an additional columns named edit and delete in the list.rhtml of books view.
Look at the edit method in the above image. Please note that I have not added an exception handling mechanism as of now, but when developing an application more focus has to given on handling exception.
Information about Ajax can be found at http://prototypejs.org/api/ajax. So once the edit button of the list page is clicked , we would populate the contents of book for editing.
Once you make the necessary changes click the submit button.The request would be sent to the update method and there we have a check to make sure whether its a new entry to the database or a update of the existing entry. Please look at the code given in the following link. http://www.box.com/s/b4d5356d6fb3b15465fd
Let us look at the delete functionality.
So I guess we are now able to add ,delete , modify a simple book keeping application. I know its very very basic , but its only the basic thats makes us concrete in future.