I am attempting to use best_in_place with datatables to allow for updating of table entries in-line. However, I have everything rendering correctly and can edit the entry, the change does not persist and same to the database and throws the log below. At present I am just looking to edit the store id and address information:
Started PUT "/locations/104" for 127.0.0.1 at 2015-05-02 16:15:17 -0400
Started PUT "/locations/104" for 127.0.0.1 at 2015-05-02 16:15:17 -0400
Processing by LocationsController#update as JSON
Processing by LocationsController#update as JSON
Parameters: {"location"=>{"address"=>"90000"}, "authenticity_token"=>"B0Eshgp8
OCRi5YJQOs+orNRo9VOMmRgyaO4fc3nEDzs=", "id"=>"104"}
Parameters: {"location"=>{"address"=>"90000"}, "authenticity_token"=>"B0Eshgp8
OCRi5YJQOs+orNRo9VOMmRgyaO4fc3nEDzs=", "id"=>"104"}
←[1m←[36mLocation Load (0.0ms)←[0m ←[1mSELECT `locations`.* FROM `locations`
WHERE `locations`.`id` = 104 LIMIT 1←[0m
←[1m←[36mLocation Load (0.0ms)←[0m ←[1mSELECT `locations`.* FROM `locations`
WHERE `locations`.`id` = 104 LIMIT 1←[0m
←[1m←[35m (0.0ms)←[0m BEGIN
←[1m←[35m (0.0ms)←[0m BEGIN
←[1m←[36m (0.0ms)←[0m ←[1mCOMMIT←[0m
←[1m←[36m (0.0ms)←[0m ←[1mCOMMIT←[0m
Completed 204 No Content in 8ms (ActiveRecord: 0.0ms)
Completed 204 No Content in 8ms (ActiveRecord: 0.0ms)
[2015-05-02 16:15:17] WARN Could not determine content-length of response body.
Set content-length of the response or set Response#chunked = true
locations.html.erb:
<% if @restaurant.locations.any? %>
<h1>Manage <%= @restaurant.name.pluralize %> Restaurant Locations</h1>
<button id="deleteLocations">Delete Restaurant</button>
<button id="selectAllLocations">Select All</button>
<button id="deSelectAllLocations">Deselect All</button>
<table id="restaurantLocations" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>id</th>
<th>Store Number</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Zip Code</th>
<th>Major City Bidding</th>
<th>Sit Down?</th>
<th>Drive Through?</th>
</tr>
</thead>
<tfoot id="input">
<th>id</th>
<th>Store Number</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Zip Code</th>
<th>Major City Bidding</th>
<th>Sit Down?</th>
<th>Drive Through?</th>
</tr>
</tfoot>
<%# current_user.locations.each do |branch| %>
<tbody>
<% @restaurant.locations.where(removed: 0).each do |branch| %>
<tr>
<td><%= branch.id %></td>
<td><%= best_in_place branch, :store_number %></td>
<td><%= best_in_place branch, :address %></td>
<td><%= branch.city_name %></td>
<td><%= branch.state.upcase %></td>
<td><%= branch.zip %></td>
<td><%= City.where(id: branch.city_id).pluck(:city).first %></td>
<td><%= branch.sit_down %></td>
<td><%= branch.drive_through %></td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<h1>Upload <%= @restaurant.name.pluralize %> Restaurant Locations</h1>
<p>Simply format your CSV file as the sample:(INSERT EXAMPLE) and upload</p>
<% end %>
location controller:
def update
@location = Location.find(params[:id])
@location.update(params[:address])
respond_with @location
end
private
def location_params
params.require(:location).permit(:address)
end
locations.js.coffee:
jQuery ->
console.log("locations.coffee loaded")
$('.best_in_place').best_in_place()
来源:https://stackoverflow.com/questions/30007030/datatables-with-best-in-place-not-allowing-updating