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!
@GorailsTV4 жыл бұрын
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.
@MassimoDeMarchiyolo2 жыл бұрын
@@GorailsTV Is the Trello clone video published anywhere?
@doitwithdevon3 жыл бұрын
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.
@inmydelorean60253 жыл бұрын
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 Жыл бұрын
Where is the nested sortable episode ?
@ShadabAli-gs3eo3 жыл бұрын
There is any way to do the same with react and material UI? @GoRails
@BrazenNL3 жыл бұрын
Where are the classes like mb-4 defined that I see you using regularly?
@GorailsTV3 жыл бұрын
In Bootstrap and Tailwind
@josephcaughlin5883 жыл бұрын
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.
@GorailsTV3 жыл бұрын
It might just be CSS? Your elements probably need to be all inline blocks
@josephcaughlin5883 жыл бұрын
@@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.
@SouravTechLabs4 жыл бұрын
Why on `Rails.ajax({...})` am I getting ReferenceError: Rails is not defined?
@M3lfQuin4 жыл бұрын
import Rails from "@rails/ujs"
@mikopiko2 жыл бұрын
This is Amazing!
@bhaktikulkarni50894 жыл бұрын
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?
@vncntc81654 жыл бұрын
Hello rails newbie here. Which do you think would be better to use between jquery-ui sortable and this?
@GorailsTV4 жыл бұрын
Nothing wrong with using jQuery! This is more flexible to use your own design though.
@IvanRaszl4 жыл бұрын
Awesome as always! Thanks!
@GorailsTV4 жыл бұрын
🤘
@mouhamaddiop11443 жыл бұрын
Very very usefull. Thanks a lot
@carlosmorin19234 жыл бұрын
Very useful, thanks!
@withrejkapermana60874 жыл бұрын
can you put your rails version sir?
@GorailsTV4 жыл бұрын
Rails 6
@YaroslavShmarov4 жыл бұрын
but why stimulus? can't we just use plain javascript for it?
@GorailsTV4 жыл бұрын
Stimulus makes it so we don't have to do any fancy turbolinks compatibility. Check out our other episodes on Stimulus.
@yanikcrepeau4852 жыл бұрын
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 Жыл бұрын
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)), }); }
@ttovarischh2 жыл бұрын
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? :(((