sortable_element... "No action responded to sort."

Subscribe to sortable_element... "No action responded to sort." 4 post(s), 3 voice(s)

 
Avatar Scott 1 post

I believe I have copied the code correctly from the book on this one, but when I try to sort items by dragging and dropping, the server pipes up with an ActionController::UnknownAction, claiming that nothing would respond to sort. :(

Is this caused by using Rails 2.3.2?

in index.html.erb:

<%= sortable_element ‘todo-list’, :url => { :action => “sort”, :id => @today }, :complete => visual_effect(:highlight, ‘todo-list’) %>

in today_controller.rb:

def sort
  @today.todos.each do |todo|
    todo.position = params['todo_list'.index(todo.id.to_s) +1]
    todo.save
  end
  render :nothing => true
end
 
Avatar mongo 8 post(s)

It appears you may have a typo. I believe the line you have as

todo.position = params['todo_list'.index(todo.id.to_s) + 1]

should be like this (note where the closing right brace is):
todo.position = params['todo_list'.index(todo.id.to_s)] + 1

Hope that helps. I’m just getting started on this whole Ruby/Rails thing so take any posts I enter with a grain of salt…

 
Avatar EldonAlameda Administrator 216 post(s)

Were you able to get this working? I’m not seeing the difference in the two lines of code that you posted.

 
Avatar mongo 8 post(s)

Sorry. It was a copy and paste typo in my response to the original post. I have since edited my post.