Rails and ajax update record on single page

298 Views Asked by At

i'm trying to create an edit page in Rails which has two panels, the top panel has a select box containing all projects, and an edit button. When a project is selected and the edit button pressed, the edit form in the second panel should populate with that project to update.

Unfortunately I don't appear to be able to get the pattern for the form in the top panel right, or the supporting methods.

I understand how to make it work listing all projects on one page, and clicking a link_to edit which takes you to the edit page, but having it all on one page with the two panels as described above escapes me.

My first form look a bit like this:

<%= form_tag(edit_project_editor_path) do -%>
  <b>Filter:</b>
  <input type="text" onkeyup="MyUtil.selectFilter('select-list', this.value)" /><br>
  <select id="select-list" size="5" style="width:200px">
    <% for project in @projects %>
      <option name="id" value="<%= project.id %>"><%= project.name %></option>
    <% end %>
  </select>
  <%= submit_tag 'Edit' %>
<% end -%>

The first issue is that it doesn't like the form having an "edit" without providing the id param, it tries to tell me the route to "edit" on "project_editor" doesn't exist, which it does.

I can't help feeling I am making this far more complicated than it really needs to be, but my limited exposure to rails has me hitting a brick wall.

Any pointers to any doco which might assist me in getting this pattern working would be very much appreciated.

0

There are 0 best solutions below