2

I'm trying to edit multiple records using one form, so the user can edit a few records then press submit at the end rather than after each individual one. I've posted my current code, and I get this error:

undefined method `connection_connection_path'

Controller

def show
  @customer = Customer.find(params[:id])
  @connection = @customer.connections
  respond_to do |format|
    format.html # show.html.erb
    format.json { render json: @customer }
  end
end

View

<table class="table">
    <thead>
        <th>Interface</th>
        <th>Device</th>
        <th>Speed</th>
        <th>Site</th>
        <th>Capable</th>
        <th>Notes</th>

    </thead>
    <%= form_for(@connection) do |f| %>
    <% @connection.each do |l| %>
    <tr>
        <td><%= l.interface %></td>
        <td><%= l.device %></td>
        <td><%= l.speed %></td>
        <td><%= l.site.name%> </td>
        <td><%= f.check_box :check %></td>
        <td><%= f.text_field :notes %></td>

    </tr>
    <% end %>
            <tr><%= f.submit %></tr>
</table>
<% end %>

routes

resources :connections


resources :sites


resources :customer_sites


resources :customers

root :to => "customers#index"
user1738017
  • 609
  • 2
  • 12
  • 29

1 Answers1

0

so where is your submit button?? and it should not done in show, maybe you might create a new method in your controller and do the multiple edit function.

The basic concept is when you have checks, you need to pass an array of your object to your method, and update them one by one. or you can do that using JS as well.

refer this railscast http://railscasts.com/episodes/165-edit-multiple

and this stackoverflow Rails 3 Edit Multiple Records in a Single Form

these resources you can get easily by google :D if still have problem, just come and ask here again

Community
  • 1
  • 1
Nich
  • 1,112
  • 1
  • 14
  • 29
  • I've updated my question with a submit button, I don't understand how to do a multiple edit function.. that's part of my question! – user1738017 May 23 '13 at 16:14
  • Thanks, I think I've got a bit further with the stackoverflow answer.. I'll see if I can get it to work! – user1738017 May 23 '13 at 16:27