Save 36% for Black Friday! Learn more

David Van Der Beek


130 Experience
1 Lesson Completed
0 Questions Solved


You should be able to do this with the Apartment gem. Check out the docs, specifically this section

Posted in Sortable Drag and Drop Discussion

Here's another implementation that avoids excess queries and lets you use the standard update controller action. It uses the insert_at method that acts_as_list provides to move the item within the list:

# app/models/question.rb
def new_position=(position)

Make sure to add :new_position to permitted params in questions controller

# coffeescript
$(document).on 'turbolinks:load', ->
axis: 'y'
handle: '.handle'
update: (e, ui) ->
data = new FormData
data.append "question[new_position]", ui.item.index() + 1
url: "/questions/#{'question-id')}"
type: "PATCH"
data: data

Posted in Refactoring Controller Methods Discussion

Looks like you also have an extra param in that send method. It doesn't need to accept the to_phone_number since you have it in your initialize method. Also, you probably need to pass to_phone_number to your default_response method.

logo Created with Sketch.

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

© 2022 GoRails, LLC. All rights reserved.