Dynamic Select Fields in Rails using Hotwire

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

GoRails

GoRails

Күн бұрын

► Check out gorails.com for Pro episodes and more!
► SaaS business template for Ruby on Rails with built-in features like Payments, Teams, and much more: jumpstartrails...
► Ruby on Rails hosting with Hatchbox.io: hatchbox.io
► Learn how to add Stripe Payments (with SCA support!) with Ruby on Rails: courses.gorail...

Пікірлер: 45
@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!
@richarddana2603
@richarddana2603 Жыл бұрын
SIRRR!!!!! You are my Knight in SHIMMERING armor
@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!
@elissonmichael2807
@elissonmichael2807 2 жыл бұрын
Thanks for sharing.
@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"
@igorpenkovsky3209
@igorpenkovsky3209 3 жыл бұрын
Nice, thanks!
@jheathco
@jheathco Жыл бұрын
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 10 ай бұрын
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
@cmthimmaiah
@cmthimmaiah Жыл бұрын
Awesome video, thank you
@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?
@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
@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.
@grahambinho
@grahambinho 2 жыл бұрын
Great video. Do you have a tutorial video on 'collection_check_boxes'?
@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 ?
@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. 👍
@whyimustusemyrealname3801
@whyimustusemyrealname3801 2 жыл бұрын
anyone have example for typeahead combobox ?
@mutigersuaheli8444
@mutigersuaheli8444 2 жыл бұрын
Hello, can you tell me how I can fill a simple text field dynamically in this way?
@GorailsTV
@GorailsTV 2 жыл бұрын
Your turbo stream would probably need to replace the text field with one that's filled out.
@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
@bristinachristian1366
@bristinachristian1366 3 жыл бұрын
Make video on pagination without gem with dropdown filter
@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.
@je9625
@je9625 2 жыл бұрын
Is it me or is the code complex ?
@GorailsTV
@GorailsTV 2 жыл бұрын
It takes some getting used to. I found turbo confusing for a while.
Datatables in Rails from Scratch with Hotwire | Preview
3:05
Hotwire Demystified - Jamie Gaskins
34:18
Ruby Central
Рет қаралды 11 М.
Inside Out 2: BABY JOY VS SHIN SONIC 3
00:19
AnythingAlexia
Рет қаралды 7 МЛН
Как мы играем в игры 😂
00:20
МЯТНАЯ ФАНТА
Рет қаралды 3 МЛН
From Small To Giant Pop Corn #katebrush #funny #shorts
00:17
Kate Brush
Рет қаралды 68 МЛН
Inline Editing with Turbo Frames in Rails
20:39
GoRails
Рет қаралды 13 М.
How to use Hotwire in Rails
24:26
GoRails
Рет қаралды 55 М.
Select or Create Field with Selectize.js
27:26
GoRails
Рет қаралды 16 М.
How to use Dev Containers in Rails 7.2
24:07
GoRails
Рет қаралды 4,2 М.
Digging into Turbo with Ruby on Rails 7
44:50
webcrunch
Рет қаралды 16 М.
Rails 7: The Demo
34:15
David Heinemeier Hansson
Рет қаралды 107 М.
Hotwire: The Demo
12:55
Getting Real
Рет қаралды 37 М.
Ruby on Rails #80 Dynamic Forms with Turbo (not JS approach)
18:23
Inside Out 2: BABY JOY VS SHIN SONIC 3
00:19
AnythingAlexia
Рет қаралды 7 МЛН