Edit form updating with text

NickT

Your error is coming from you thinking about handling the response in the template instead of the controller.

The data the form helpers display comes from the Model objects (usually from database tables). So you need to make sure that the update_album method in the controller is correctly initialising an instance of the album class (model). eg. @album contains valid data.

Overall, as a structural suggestion, take the two parts of the form in your if condition, and make them separate partials, eg _update_detail and _list_detail. Then, in the controller methods album and update_album set up a control variable eg. @album_detail='update_detail' or @album_detail='list_detail'

Then you can replace all of the code between the if/end in your view with render :partial=>@album_detail

This puts all your logic back into the controller and removes the need to test for request? and also gives you an arrangement that readily lends itself to an Ajax call. You only have to put an id around the render statement and use that as the update parameter in the ajax call. The controller can then render :partial to do the update.

BTW, you are using a table for layout purposes, and whilst I am not obsessed with tableless layout, in this instance it will give you a problem because you will find it difficult to wrap two table rows with a common id for ajax update. You may get away with a <span>, but the browser may not like updating parts of the table in this way. I have an app that solely uses Firefox, and that doesnt mind if you use ajax to replace a whole row, using an id in the <tr>, but I havnt tried spanning multiple rows.

hth Tonypm