Results 1 to 17 of 17
Dec 30, 2005, 10:53 #1
- Join Date
- Dec 2005
- 0 Post(s)
- 0 Thread(s)
Rails: Multiple edit forms in one view
Hello. thanks in advance for your time, i hope this is a simple question.. (I'm very new (< 1 week) to ruby and rails).
I'd like to create a list view displaying all 'user' records. At the same time, each list item should be a small form with auto-filled fields and a submit button labelled 'update'.
I'm a little stuck on how to implement multiple 'edit' type forms in one view page (all the tutes ive seen deal with only a single form).
My code looks like the listing below. I didn't expect it to work, but incase it's useful to know, at the moment it results in the appropriate number of forms being created, but the fields of the forms aren't being populated:
in the controller:
flash[:notice] = 'Account was successfully updated.'
redirect_to (:action => 'list_users')
flash[:error] = 'Account couldnt be updated.'
render :action => 'list_users'
<%= render(:partial => "user_edit", :collection => @existingusers) %>
<%= form_tag :action=> "update_user", :id => user_edit %>
<%= text_field "user", "username", :size => 15 %><br/>
<%= password_field "user", "password", :size => 15 %><br/>
<label for="user_password_confirmation">Confirm password:</label><br/>
<%= password_field "user", "password_confirmation", :size => 15 %><br/>
<input type="submit" value="Update user" class="primary" />
<%= end_form_tag %>