Dynamic Select Fields in Rails using Hotwire

  Рет қаралды 25,641

GoRails

GoRails

Күн бұрын

Пікірлер: 46
@lucassanco28
@lucassanco28 2 ай бұрын
Thanks for sharing, explained perfectly!
@richarddana2603
@richarddana2603 Жыл бұрын
SIRRR!!!!! You are my Knight in SHIMMERING armor
@ricardomordaunt1101
@ricardomordaunt1101 2 жыл бұрын
Chris is a genius when it comes to programming.. it's all Greek to me.. how do you understand it all.. You are truly in a league of your own in my opinion.. Thank you for this tutorial
@deybmen
@deybmen 3 жыл бұрын
Just what i needed for my current project
@GorailsTV
@GorailsTV 3 жыл бұрын
Love when a screencast comes out at the perfect time!
@deybmen
@deybmen 3 жыл бұрын
@@GorailsTV thank you!
@anthonypetruzzi158
@anthonypetruzzi158 3 жыл бұрын
.invert 😲 where has that been my whole life. I don't do rails anymore 😭 but I just LOVE watching your videos 💘
@defsdoor
@defsdoor 3 жыл бұрын
I really liked this video, generally but primarily for one reason. It confirmed that I was on the right track with my own dive in to stimulus and turbo. There's not a lot of information out there still and, for turbo/turbo frames especially, it's very much still a moving target.
@GorailsTV
@GorailsTV 3 жыл бұрын
It sure is. Luckily it's becoming easier and easier to use and more tutorials now that we've had time to learn and use it for a few months.
@kwhandy
@kwhandy 3 жыл бұрын
dude please add more hotwire-related content this semester. you also need to update any existing content that already done with turbolinks/UJS, like button loading spinner and love/like/follow button.
@GorailsTV
@GorailsTV 3 жыл бұрын
It's coming!
@jheathco
@jheathco 2 жыл бұрын
Great work. What about when editing an address to have the list of states pull on page load based on the record's existing country?
@dabiraakinwumi8698
@dabiraakinwumi8698 Жыл бұрын
hey i ran into the same issue and i solved it by getting the id of the existing record from the url params. Then calling my model from my controller e.g Address.find[:id]. Once you know what country is attached to the current address you can get the list of states and attach it to the page on page load using stimulus. Thats the basic idea
@shannonmariehauck
@shannonmariehauck Жыл бұрын
This is awesome! I need to figure out a slight variation: suppose there are too many countries for a form.select field. Think of millions of countries. How could it use an autocomplete search to display only matching options for the user to select. Thank you!
@GorailsTV
@GorailsTV Жыл бұрын
A Javascript library like TomSelect is handy for this. You can have it load the options via AJAX requests and also filter those results remotely.
@jayjreg
@jayjreg 2 жыл бұрын
Failed to register controller: country (controllers/country_controller) TypeError: Failed to resolve module specifier "@rails/request.js". Relative references must start with either "/", "./", or "../".
@jayjreg
@jayjreg 2 жыл бұрын
Could not find a declaration file for module '@rails/request.js'.
@jayjreg
@jayjreg 2 жыл бұрын
Error invoking action "change->select#change"
@grahambinho
@grahambinho 2 жыл бұрын
Great video. Do you have a tutorial video on 'collection_check_boxes'?
@BorisBarroso
@BorisBarroso 2 жыл бұрын
This is nice, how it would work if you set the value of the country in the form? I think we should make changes to the *change* function to make it work
@cmthimmaiah
@cmthimmaiah Жыл бұрын
Awesome video, thank you
@elissonmichael2807
@elissonmichael2807 3 жыл бұрын
Thanks for sharing.
@angeluray9211
@angeluray9211 Жыл бұрын
How could I integrate this functionality with the registration form of devise, I want to let my users select the country they're from or live.
@SEOng-gs7lj
@SEOng-gs7lj 2 жыл бұрын
possible to show the turbo progress bar when the request.js GET is slow?
@RohanDaxini
@RohanDaxini 2 жыл бұрын
Thanks for this tutorial Chris. Very helpful. Somehow just for my setup (Rails 7.0.1 and Ruby 3.0.0) the request.js didn't work for me directly while using it in country_controller.js (or select_controller.js). In other words, despite doing that step, and then calling get() function, it was unable to do anything. Though, I followed the exact step from this tutorial i.e. using "yarn add @rails/request.js". So I had to still install request.js using gem "requestjs-rails" and then running "rails requestjs:install". The earlier yarn step also added dependency in package.json but still, it was not working. After using gem and installing request.js step with rails command, it added the import statement for "rails/request.js" in import application.js. Everything worked fine after this step. It's strange but that's how it worked for me. Letting you know here just in case it helps anybody else facing the same issue.
@amazingcake7023
@amazingcake7023 2 жыл бұрын
Did you import the " { get } from '@rails/request.js' ". I've the same setup as you and mine is not working.
@amazingcake7023
@amazingcake7023 2 жыл бұрын
i still get this error message "Uncaught TypeError: Failed to resolve module specifier "rails/request.js". Relative references must start with either "/", "./", or "../". "
@RohanDaxini
@RohanDaxini 2 жыл бұрын
@@amazingcake7023 Yes I have "import { get } from "@rails/request.js"" in country_controller.js as well otherwise it wasn't working.
@RohanDaxini
@RohanDaxini 2 жыл бұрын
@@amazingcake7023 did you try importing i.e. import "@rails/request.js" in your application.js ?
@igorpenkovsky3209
@igorpenkovsky3209 3 жыл бұрын
Nice, thanks!
@kristianpapadakis996
@kristianpapadakis996 Жыл бұрын
How would you extend this to also select a city from a given state?
@GorailsTV
@GorailsTV Жыл бұрын
You'd do the same thing when the state changes and load a list of cities from the Rails app.
@kristianpapadakis996
@kristianpapadakis996 Жыл бұрын
Thank you, Chris@@GorailsTV
@Kami84
@Kami84 2 жыл бұрын
I need to do this for state and county within the US. As in user selects state and the second drop down will list counties within that state. There is not gem for this that I have found. How would I do this if there is no gem that I can use? I am also new to ruby on rails.
@GorailsTV
@GorailsTV 2 жыл бұрын
You could load a CSV or make a database model for the counties. Doesn't really matter where you store the data. 👍
@mutigersuaheli8444
@mutigersuaheli8444 3 жыл бұрын
Hello, can you tell me how I can fill a simple text field dynamically in this way?
@GorailsTV
@GorailsTV 3 жыл бұрын
Your turbo stream would probably need to replace the text field with one that's filled out.
@whyimustusemyrealname3801
@whyimustusemyrealname3801 3 жыл бұрын
anyone have example for typeahead combobox ?
@bristinachristian1366
@bristinachristian1366 3 жыл бұрын
Make video on pagination without gem with dropdown filter
@samuelfaure4332
@samuelfaure4332 2 жыл бұрын
Very good tutorial, but it would be amazing if you showed some tests too (with rspec/capybara for example)
@MichalDudkiewicz-m7g
@MichalDudkiewicz-m7g Жыл бұрын
he do something but source to download is build completly different
@je9625
@je9625 3 жыл бұрын
Is it me or is the code complex ?
@GorailsTV
@GorailsTV 3 жыл бұрын
It takes some getting used to. I found turbo confusing for a while.
@spryffee-old
@spryffee-old Жыл бұрын
This approach does not work if you have another controller (e.g. slim-select) set for the select fields
@GorailsTV
@GorailsTV Жыл бұрын
You would modify it to update slim select options instead.
Datatables in Rails from Scratch with Hotwire | Preview
3:05
How to use Hotwire in Rails
24:26
GoRails
Рет қаралды 56 М.
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 145 МЛН
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
Ruby on Rails #80 Dynamic Forms with Turbo (not JS approach)
18:23
Inline Editing with Turbo Frames in Rails
20:39
GoRails
Рет қаралды 14 М.
Hotwire Demystified - Jamie Gaskins
34:18
Ruby Central
Рет қаралды 11 М.
Refactoring Turbo Streams into Turbo Frames
10:54
GoRails
Рет қаралды 4,3 М.
Exploring Rails 7, Hotwire and AnyCable speedy streams
38:19
Evil Martians
Рет қаралды 7 М.
Rails 7: The Demo
34:15
David Heinemeier Hansson
Рет қаралды 109 М.
Hotwire: The Demo
12:55
Getting Real
Рет қаралды 38 М.