How To Build a Powerful Search Form With Hotwire

Поделиться
HTML-код
  • Опубликовано: 18 ноя 2024

Комментарии • 31

  • @jordanell4236
    @jordanell4236 2 года назад +6

    I'm coming back to rails for the first time since Rails 4. Thank you for everything you are doing to support the Rails ecosystem and in particular Rails 7!

    • @mixandgo
      @mixandgo  2 года назад

      Welcome back Jordan :) A lot has changed since v4.

  • @traviszito6408
    @traviszito6408 Год назад +1

    Really like your explanation here, very clear and you didn't rush through things too fast. Was able to get search in my app up and running in no time!

  • @ledockol
    @ledockol 2 года назад +1

    Great video. Many thanks to the author!
    A few notes:
    1) Stimulus action without bind function:
    this.submit = debounce(this.submit, 300)
    submit = () -> {
    this.element.requestSubmit()
    }
    Like this: github -> secretpray (Hotwire-CRUD-MODAL) in search_controller.js
    2) I would also add search launch only after two characters entered, reset search results (in turbo_frame), user search history.

    • @mixandgo
      @mixandgo  2 года назад

      Thank you for your suggestions

  • @TheStalinBR
    @TheStalinBR 8 месяцев назад

    Loved the debounce hint.

    • @mixandgo
      @mixandgo  8 месяцев назад

      I'm glad you found it helpful.

  • @acidtib
    @acidtib Год назад

    thank you for the video, you just made it all click in my head.

  • @kelvin.s420
    @kelvin.s420 Год назад

    Excellent video. Thank you!

  • @ReizRobert
    @ReizRobert Год назад

    Very useful video. Thx for sharing!

  • @muniruddin8295
    @muniruddin8295 Год назад

    Nice one and super helpful. Thanks for sharing!

    • @mixandgo
      @mixandgo  Год назад

      Glad it was helpful!

  • @hardikvekariya8067
    @hardikvekariya8067 Год назад

    amazing tutorial men!!

  • @a79rtur
    @a79rtur 2 года назад

    debounce part pretty interesting

  • @cmthimmaiah
    @cmthimmaiah 2 года назад

    Amazing, thank you

    • @mixandgo
      @mixandgo  2 года назад

      You're welcome :)

  • @daniloalves7440
    @daniloalves7440 2 года назад +1

    I'm from a Django background and I'm studying ruby but I was curious about how things are done in Rails
    I see this video just for curiosity and I like that so much because it's so simple!

    • @mixandgo
      @mixandgo  2 года назад +1

      Yes, that's what attracted a lot of people to it.

  • @bennadel
    @bennadel Год назад

    This was really great, thank you. I'm currently trying to learn Hotwire after Angular, which is a very different mental model. Seeing the search form work in combination with turbo-frames and the search action on the main controller was great. But, I've also run into issues where Hotwire requires a Form post to result in a Location redirect (or throws an error). I see in your demo that you're using a GET request; I assume this is (in part) to get around this issue (and in part to make the URL shareable). Just wondering if you have any advice for something like this where it has to be a POST... though, I guess I could use a turbo-stream at that point. Anyway, awesome stuff!

    • @mixandgo
      @mixandgo  Год назад

      I'm not sure I understand your question. Is there a reason you cannot use a POST?

    • @bennadel
      @bennadel Год назад

      @@mixandgo In this case, you're re-rendering the same page with the form submission. Turbo Drive requires POST requests to either result in an error or in a 3xx page redirect. But, by using the GET request, you can get around that limitation. Unless, you respond with a Turbo Stream. Anyway, I don't mean to go off on a tangent. It's a great video - this stuff is just swimming around in my brain.

  • @videoeditorshiva
    @videoeditorshiva 2 года назад

    I did not try Hotwire yet but was curious can we apply this in api only application of rails

    • @mixandgo
      @mixandgo  2 года назад +1

      Not really. It's for building UIs.

  • @gomitchell
    @gomitchell 2 года назад

    You loaded the denounce using yarn. Do you need to use webpacker to load the JS? I thought rails 7 uses import maps to load JS dependencies?

    • @mixandgo
      @mixandgo  2 года назад

      You don't need to, but the option is still available.