Drag and Drop Sortable Lists in Ruby on Rails

  Рет қаралды 17,555

GoRails

GoRails

Күн бұрын

Пікірлер: 31
@julianpinzoneslava
@julianpinzoneslava 4 жыл бұрын
I’m loving the episodes where you use Stimulus. I think is SO important for someone to demystify it and I’m glad you’re doing it. Keep ‘em coming man! They’re amazing!
@GorailsTV
@GorailsTV 4 жыл бұрын
And it's always surprisingly simple it seems. I just built a trello clone in like 25 lines of code. It's kinda crazy. Will be publishing that soon.
@MassimoDeMarchiyolo
@MassimoDeMarchiyolo 2 жыл бұрын
@@GorailsTV Is the Trello clone video published anywhere?
@doitwithdevon
@doitwithdevon 3 жыл бұрын
Fantastic video, maybe I missed it or maybe I didn't, either way, in drag_controller.js you must have an import for Rails... so: import Rails from '@rails/ujs' -- if you get Rails is not defined error. Thank you.
@inmydelorean6025
@inmydelorean6025 3 жыл бұрын
Thanks for the tutorial Chris, it's great. But I think this implementation will fail for all but trivial scenarios. Assigning position value to an item based on its position in the list will work for the newly created untouched list but let's say I have a list of 15 todos. I've completed most of them and left with tasks 5 (first), 10 (second), 15 (third). Now, when I move task 5 to the bottom of the list it will be assigned with the position of 3 since it's third now. But tasks 10 and 15 have corresponding position values and will stay in the second and third positions. The only way to move task 5 to the third position in the list is to move tasks 10 and 15 up so that they are assigned with positions 1 and 2. There are other issues but it's a simple one. It will also fail when different users manage their to-do lists, they will be overriding each other's tasks positions. I still think it's a great tutorial overall, just wanted to warn anyone who'd like to implement it in production.
@dp2586
@dp2586 Жыл бұрын
Where is the nested sortable episode ?
@ShadabAli-gs3eo
@ShadabAli-gs3eo 3 жыл бұрын
There is any way to do the same with react and material UI? @GoRails
@BrazenNL
@BrazenNL 3 жыл бұрын
Where are the classes like mb-4 defined that I see you using regularly?
@GorailsTV
@GorailsTV 3 жыл бұрын
In Bootstrap and Tailwind
@josephcaughlin588
@josephcaughlin588 3 жыл бұрын
Do you have any suggestions for a sortable card-grid. SortableJS has a grid example on their page, but I can't find any documentation to see how they achieved that. I am using CSS-Grids to create a responsive card grid, but when I add the data-controller, my grid is rendered as a list. I am not seeing anything in the inspector to indicate what is happening.
@GorailsTV
@GorailsTV 3 жыл бұрын
It might just be CSS? Your elements probably need to be all inline blocks
@josephcaughlin588
@josephcaughlin588 3 жыл бұрын
@@GorailsTV I reverted to bootstrap. This ugly line of html fixed it: . That fixed it. I can say I tried to do about everything. The data-controller has to be in the div immediately preceding the element that one wants to sort? For what ever reason, putting on its one line causes some sort of conflict. I tried to add an attribute class. Now, I get to the fun part which is to make sure I can get this to persist with my many-to-many table.
@SouravTechLabs
@SouravTechLabs 4 жыл бұрын
Why on `Rails.ajax({...})` am I getting ReferenceError: Rails is not defined?
@M3lfQuin
@M3lfQuin 4 жыл бұрын
import Rails from "@rails/ujs"
@mikopiko
@mikopiko 2 жыл бұрын
This is Amazing!
@bhaktikulkarni5089
@bhaktikulkarni5089 4 жыл бұрын
I'm a newbie in ruby on rails. I have two controllers for the same model in index page of both of these controllers we can reorder. I want different ordering systems in both. Meaning postion for one controller and maybe other_position for the other controller. Is this possible?
@vncntc8165
@vncntc8165 4 жыл бұрын
Hello rails newbie here. Which do you think would be better to use between jquery-ui sortable and this?
@GorailsTV
@GorailsTV 4 жыл бұрын
Nothing wrong with using jQuery! This is more flexible to use your own design though.
@IvanRaszl
@IvanRaszl 4 жыл бұрын
Awesome as always! Thanks!
@GorailsTV
@GorailsTV 4 жыл бұрын
🤘
@mouhamaddiop1144
@mouhamaddiop1144 3 жыл бұрын
Very very usefull. Thanks a lot
@carlosmorin1923
@carlosmorin1923 4 жыл бұрын
Very useful, thanks!
@withrejkapermana6087
@withrejkapermana6087 4 жыл бұрын
can you put your rails version sir?
@GorailsTV
@GorailsTV 4 жыл бұрын
Rails 6
@YaroslavShmarov
@YaroslavShmarov 4 жыл бұрын
but why stimulus? can't we just use plain javascript for it?
@GorailsTV
@GorailsTV 4 жыл бұрын
Stimulus makes it so we don't have to do any fancy turbolinks compatibility. Check out our other episodes on Stimulus.
@yanikcrepeau485
@yanikcrepeau485 2 жыл бұрын
Everything when fine on my side until I have the following error messge (ruby on rails console): ActionController::InvalidAuthenticityToken (Can't verify CSRF token authenticity.):
@ellyambet4608
@ellyambet4608 Жыл бұрын
Awesome video Chris. Since: Rails.ajax ({ url: this.data.get("url").replace(":id", id), type: 'PATCH', data: data }) Depends on, @rails/ujs, This other option works for me without importing, @rails/ujs. ----> end(event) { const id = event.item.dataset.id; const data = new FormData(); data.append("position", event.newIndex + 1); fetch(this.data.get("url").replace(":id", id), { method: 'PATCH', headers: { 'X-CSRF-Token': document.getElementsByName('csrf-token')[0].content, 'Content-Type': 'application/json', }, body: JSON.stringify(Object.fromEntries(data)), }); }
@ttovarischh
@ttovarischh 2 жыл бұрын
Hi! Thank you so much for your videos!!! You are an incredible teacher. I am somehow getting the error "PATCH localhost:3000/events/6/move 404 (Not Found)" each time I move an item. Do you know why? :(((
Infinite Scroll with Stimulus.js & Rails
15:18
GoRails
Рет қаралды 9 М.
Rate Limiting Requests in Rails 7.2
20:09
GoRails
Рет қаралды 2,5 М.
PIZZA or CHICKEN // Left or Right Challenge
00:18
Hungry FAM
Рет қаралды 15 МЛН
The Ultimate Sausage Prank! Watch Their Reactions 😂🌭 #Unexpected
00:17
La La Life Shorts
Рет қаралды 6 МЛН
КОГДА К БАТЕ ПРИШЕЛ ДРУГ😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 8 МЛН
Trick-or-Treating in a Rush. Part 2
00:37
Daniel LaBelle
Рет қаралды 45 МЛН
Introduction to Stimulus Reflex
10:11
GoRails
Рет қаралды 17 М.
How to get started with Kamal 2
16:43
Sam Johnson
Рет қаралды 727
5 Secrets to Becoming a Badass Ruby on Rails Developer
28:01
Mix & Go
Рет қаралды 25 М.
Rails World 2023 Opening Keynote - David Heinemeier Hansson
1:02:20
Ruby on Rails
Рет қаралды 86 М.
The Art of Code - Dylan Beattie
1:00:49
NDC Conferences
Рет қаралды 4,7 МЛН
Rails vs JavaScript: Which one should you use for your SaaS?
12:50
The Ruby On Rails Junior Developer Problem
16:03
Deanin
Рет қаралды 20 М.
Stimulus JS Framework Introduction
18:51
GoRails
Рет қаралды 19 М.
PIZZA or CHICKEN // Left or Right Challenge
00:18
Hungry FAM
Рет қаралды 15 МЛН