Reputation: 634
I have a Rails 2.3.18 app that allows users to drag and drop items in a list. I am receiving the following error when users drag and drop:
ActionView::MissingTemplate (Missing template lists/sorting.erb in view path app/views)
Below is the related javascript. I know that Rails is looking for a template, but I'm not sure what I should point users to because I'd like for them to just stay on the page but be able to work on their list. Sorry, I'm pretty inexperienced!
// Lists Sorting
$('#items').sortable({
stop: function() {
$.post('/lists/sorting', { item_sort: $('#items').sortable('serialize') });
}
});
Upvotes: 0
Views: 57
Reputation: 18647
Since you used, $.post('/lists/sorting')
, I assume that you have listing controller
and sorting
method in that controller.
If you want to use ajax requests and dont want the erb
files, just use json
response. If you use json response, the rails will not search for an erb
file,
Try this in your controller.
class ListsController < ApplicationController
def sorting
@lists = List.find(params[:id]) // Your line here
render json: @lists
end
end
Now this json
response will be returned to your ajax call.
Upvotes: 0
Reputation: 716
I can assume you have lists_controller with sorting method. In your case the view file is missing for your request. It actually a Ajax request so it will be resolved once you add sorting.js.erb file in views/lists path.
Upvotes: 1