Ruby on Rails #80 Dynamic Forms with Turbo (not JS approach)

  Рет қаралды 6,060

SupeRails

SupeRails

Күн бұрын

Learn how to add fields to a form dynamically based on your selection in previous fields
Episode Source Code: github.com/corsego/80-turbo-d...
0:00 Intro
1:05 Scaffold Posts
2:05 Conditional Validations. Enum
4:25 Conditionally Display Passcode field
5:51 Custom Form Button
9:07 Stimulus clicker
13:28 Turbo Frame
15:03 Turbo Stream inside Frame
16:52 Summary

Пікірлер: 30
@andreasandres
@andreasandres 2 жыл бұрын
bro, i think you're a modern version from ryan bates or even better.. love your tutorial, i learned much from here..
@SupeRails
@SupeRails 2 жыл бұрын
Hello Andre! Thanks a lot! I’m trying my best 🤠
@mariners_platter
@mariners_platter Жыл бұрын
I enjoy your content! Thanks so much!
@cmthimmaiah
@cmthimmaiah 10 ай бұрын
Thank you,very clearly explained
@diegogarciaspino6048
@diegogarciaspino6048 Жыл бұрын
very clear, strong base, loved
@ledockol
@ledockol 2 жыл бұрын
Дуже цікаво. Деякі речі, наприклад вбудований турбо стрим, це взагалі щось нове! Дуже за це дякую) Разом з тим, якщо вже використовуємо стімулус, то додаткова кнопка форми зайва. Додати ще одно value і сформувати запит безпосередньо у стімулус контролері, у заголовок додати очікувану відповідь у турбо стрим форматі. Одночасно цим же контролером можно контролювати зміст парамс, щоб не виводити зайвого у строчці браузера. Ярослав, ще раз дякую! Подивився як чашку гарної кави випив) Слава Україні!
@SupeRails
@SupeRails 2 жыл бұрын
Вітаю! Чи міг би ти показати що ти маєш на увазі у форматі gist? :)
@ledockol
@ledockol 2 жыл бұрын
@@SupeRails Звісно.
@danielfonsecadasilva396
@danielfonsecadasilva396 Жыл бұрын
I love you! thanks
@MarkWeiser
@MarkWeiser Жыл бұрын
Great tutorial, but I hit 2 issues: 1. simple_form does not let me create a button with get action on form (might have to bypass simple_form) 2. i got around the first problem by creating a submit button with a different commit parameter, and catch the submission in the create controller method: " if params[:commit].eql? 'validate' return render :new end" however the submit will not be invoked if html 5 is validating required fields Any ideas?
@hass89
@hass89 2 жыл бұрын
How can this be used with nested form fields (accepts_nested_attributes_for)?
@SupeRails
@SupeRails 2 жыл бұрын
if you want to "add/remove" nested fields, you would need something else. like gem vanilla_nested, or some other solution
@1990EAM
@1990EAM 8 ай бұрын
How do you show validation errors using turbo?
@ShlomoGoldenberg777
@ShlomoGoldenberg777 Жыл бұрын
Is there any way to do this without turbo?
@germancruz6484
@germancruz6484 2 жыл бұрын
what's the shortcut to back to the terminal
@SupeRails
@SupeRails 2 жыл бұрын
alt+tab? did I understand your question correctly? 😄
@baotranphi1238
@baotranphi1238 2 жыл бұрын
Can u make a video about active storage and presigned url s3 upload?
@ddd2283
@ddd2283 2 жыл бұрын
Hi Yaroslav! Can you explain turbo + action_cabe integration in some video. Thanks!
@SupeRails
@SupeRails 2 жыл бұрын
I wish I could 😂 I'll put it on the backlog +
@ddd2283
@ddd2283 2 жыл бұрын
@@SupeRails I saw it in book "modern frontend for ruby on rails" but your english more undestanable for me )))). In this book author show some intresting thing as "stimulate". I think you can explain better )))
@ddd2283
@ddd2283 2 жыл бұрын
I was wrong about naming this technology , I mean StimulusReflex , this example official kzbin.info/www/bejne/moHdp2WnqM9ogpo
@ddd2283
@ddd2283 2 жыл бұрын
Anyway , still waiting your awesome explanation😀
@SupeRails
@SupeRails 2 жыл бұрын
@@ddd2283 oh, got it! I'm aware of stimulus reflex, and I know that it can do similar things as hotwire/turbo. However I don't have enough practical experience with it to be able to cover it in a good video at the moment. SR sure is on my TODO list for when I know it well enough :)
@pftg
@pftg Жыл бұрын
It's more like an hack! You can avoid hidden button click at all.
@SupeRails
@SupeRails Жыл бұрын
Hey Paul! I wouldn't call it a hack. It's quite a reliable approach, leveraging only normal http requests and Hotwire
@clementblgr6498
@clementblgr6498 Жыл бұрын
Dont forget to enter this command after creating a stimulus controller : ./bin/rails stimulus:manifest:update
@MatthewKennedyUK
@MatthewKennedyUK 2 жыл бұрын
How do you deal with the edit side and persisting the params? Maybe use @post.assign_attributes(post_params)
@SupeRails
@SupeRails 2 жыл бұрын
interesting question. in this scenario where “new” and “edit” share the same form, I suppose it’s still ok to submit the “form.button” to “new_post_path”. If I create a record and open the edit form, everything seems to be working ok
@SupeRails
@SupeRails 2 жыл бұрын
Ok, I see an issue: when you go to "edit" and refresh the page, the selection can look "broken". I will show my solution in episode #82
@SupeRails
@SupeRails 2 жыл бұрын
Ok now I really understand where you were going. assign_attirbutes seems to be a good solution. I've used it today for a PR at work where I had to partially update an "Edit" form and worked very well
New Gadgets! Bycycle 4.0 🚲 #shorts
00:14
BongBee Family
Рет қаралды 14 МЛН
Sigma Girl Education #sigma #viral #comedy
00:16
CRAZY GREAPA
Рет қаралды 105 МЛН
Countries Treat the Heart of Palestine #countryballs
00:13
CountryZ
Рет қаралды 12 МЛН
Turbo Frame Modals (Popups) | Ruby On Rails 7 Tutorial
12:49
Refactoring Turbo Streams into Turbo Frames
10:54
GoRails
Рет қаралды 3,6 М.
Nested Attributes & Validation In Ruby On Rails 7
9:03
Deanin
Рет қаралды 5 М.
Turbo Frame Pages in Ruby on Rails 7
15:47
Deanin
Рет қаралды 7 М.
Rest API - Best Practices - Design
15:50
High-Performance Programming
Рет қаралды 96 М.
Turbo Frames vs. Turbo Streams
8:25
Mix & Go
Рет қаралды 16 М.
New Gadgets! Bycycle 4.0 🚲 #shorts
00:14
BongBee Family
Рет қаралды 14 МЛН