Next -> [[tutorials:todolist/6|Sixth Step, open and close tasks]] [[tutorials:todolist/4|Fourth Step, C, like Controller]] <- Prev Next -> [[tutorials:todolist/6|Sixth Step, open and close tasks]] [[tutorials:todolist/4|Fourth Step, C, like Controller]] <- Prev ====== Fifth Step, getting dynamic ====== We set out to build the ultimate to-do list, but there are still some things missing. First off, we want to add new tasks, so let's get that done. Add a link on the **view/index.xhtml** like this:

TodoList

New Task
Open a new file **view/new.xhtml** with a form to add a new task. TodoList

New Task

Back to TodoList
Task:
We will not need a method for this on our controller, in fact, actions can consist of either method and template or only one of them. The Controller can act as a View and the View can work like you may know it from PHP. If you try to use this form you will notice that we have not yet defined a way to actually create the task. You will get the default Ramaze error-page instead. Please take your time to explore it and see how Ramaze reacted on the error. It will show you the back trace and what state the application is in at the moment, the request and response and the contents of the session. This is very useful for debugging and development, you can provide your own set of error-pages before going into production (or deactivate them fully) though. OK, let's implement the action for #create, all we want to do is take the requests parameters and create a new task for it, this looks like following on your MainController. def create title = request['title'] TodoList[title] = {:done => false} redirect Rs() end That's all folks! We get the title from the request-object, put it into our TodoList as undone and redirect back to the mapping of the current Controller ('/' in this case). Now you can create as many tasks as you want, please don't get overworked ;) Next -> [[tutorials:todolist/6|Sixth Step, open and close tasks]] [[tutorials:todolist/4|Fourth Step, C, like Controller]] <- Prev