David Van Der Beek

Joined

130 Experience
1 Lesson Completed
0 Questions Solved

Activity

You should be able to do this with the Apartment gem. Check out the docs, specifically this section https://github.com/influitive/apartment#tenants-on-different-servers

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:

https://gist.github.com/dva...

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

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

# coffeescript
$(document).on 'turbolinks:load', ->
$('.sortable').sortable
axis: 'y'
handle: '.handle'
update: (e, ui) ->
data = new FormData
data.append "question[new_position]", ui.item.index() + 1
Rails.ajax
url: "/questions/#{ui.item.data('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.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2021 GoRails, LLC. All rights reserved.