Ruby on Rails Forms With Hotwire

Поділитися
Вставка
  • Опубліковано 15 вер 2024
  • I wanted to find out if Hotwire can be as good, or better than something like React JS. I want to know if can build a form that looks good and make it feel super responsive. But... I wasn't sure if Hotwire is up to it. So we're going to put that to the test.
    🎥 Join my new Ruby on Rails Class here: mixandgo.com/r...
    👉 Buy my Bulletproof Ruby on Rails Applications eBook: j.mp/2OtFCdR
    Link to the code repo: github.com/mix...
    You can subscribe to the channel using this link: www.youtube.co...
    My website: mixandgo.com
    #rubyonrails #rails7 #hotwire #stimulusjs #turbo #ruby #webdev

КОМЕНТАРІ • 28

  • @devdevdevdev
    @devdevdevdev 2 роки тому +1

    Awesome video, keep the good work!

  • @oooo9570
    @oooo9570 2 роки тому +2

    Yes this is what the rails community needs a revival esp. with what turbo-streams has to offer. Would you be willing to put any of this video related code on public repo?

    • @mixandgo
      @mixandgo  2 роки тому

      I might, I'm not sure yet.

  • @edmundo5450
    @edmundo5450 2 роки тому +2

    Very nice! This is what Im looking for. A form and list example using hotwire. Thank you!

    • @mixandgo
      @mixandgo  2 роки тому

      You're very welcome!

    • @edmundo5450
      @edmundo5450 2 роки тому

      @@mixandgo When the form is on edit, the field values are not blanked or reset to fields placeholders (i.e. "Your firs name" etc) after clicking Save. How to do it? Thanks again.

    • @mixandgo
      @mixandgo  2 роки тому

      @@edmundo5450 yes, that is intentional, since you're still editing (if you look at the URL, you see the ID of the record you're editing). Reset doesn't make sense (to me), but to do it you'd need to clear the form in the `update.turbo_stream.erb` template just like I did in the `create` template (i.e. render the form with a Contact.new as the contact local variable).
      I think it makes more sense to redirect to a different page, like /contacts/new in order to display an empty form.
      Hopefully, that makes sense.

    • @edmundo5450
      @edmundo5450 2 роки тому

      @@mixandgo It works!! Thanks a lot.

    • @mixandgo
      @mixandgo  2 роки тому

      You're welcome :)

  • @nelsonchavespro
    @nelsonchavespro 2 роки тому

    Thanks for posting these! I've been watching all your videos. I have a suggestion. One is creating a group, like a facebook groups, where people can join and comment and get notifications, also be able to make that group public, private, or secret. And also be able to make another user like a group admin. The other suggestion is upgrading to Rails 7 and removing webpacker.

    • @mixandgo
      @mixandgo  2 роки тому +1

      Thanks for your suggestion Nelson. Would that group be different from UA-cam (where you can comment and get notifications)? What would be the utility of the group?

    • @nelsonchavespro
      @nelsonchavespro 2 роки тому

      @@mixandgo oh I'm not familiar with youtube groups. The utility of the group is to share information and ask questions to help each other out. for example i am in a Toyota 4runner group in facebook. where people can comment, share photos, or ask questions on how to fix their car and people can comment on your post. The admin can kick people out or make other people admin as well so people don't post selling ads. and the group is private. you can ask to join and the admin will let you in. sometimes you just answer some questions and they let you automatically. I'm guessing the groups can have 3 different choices like public, private, or secret

    • @chrisrobbo
      @chrisrobbo 2 роки тому

      @@nelsonchavespro I would join :)

    • @mixandgo
      @mixandgo  2 роки тому

      @@nelsonchavespro oh I was just referring to the regular comments section and notifications that UA-cam provides (sorry if that was confusing). I see what you mean now, I do plan to create such a group for the members of the Rails course I'm building, but I haven't thought about a public one.

  • @celsomartins2293
    @celsomartins2293 2 роки тому

    Nice video. Could you please show your routes.rb? Are you using put or patch to update or just post? Thank you.

    • @mixandgo
      @mixandgo  2 роки тому +1

      You can check out the repository (in the description).

  • @tmszcncl
    @tmszcncl 2 роки тому

    Great video - thanks :) What do I need to 'play' with hotwire? Does it really require sidekiq and redis on production?

    • @mixandgo
      @mixandgo  2 роки тому

      Are you planning on using ActionCable? If so you're going to need Redis. But you can use hotwire without ActionCable, if you don't need to broadcast updates.

  • @davidcordero9864
    @davidcordero9864 2 роки тому

    After cloning the repo and running bundle I got an error.
    The asset "application.css" is not present in the asset pipeline.
    Any ideas what I can do?

    • @mixandgo
      @mixandgo  2 роки тому +1

      Have you tried running yarn? and then ./bin/dev

    • @davidcordero9864
      @davidcordero9864 2 роки тому

      @@mixandgo That worked for me thank you Cesar!

    • @mixandgo
      @mixandgo  2 роки тому

      @@davidcordero9864 happy to hear that

  • @jensdisselhoff8109
    @jensdisselhoff8109 2 роки тому

    Apart from all the turbo stuff, I really like the inline_error_for helper. Neat!

    • @mixandgo
      @mixandgo  2 роки тому

      Thanks Jens, glad you liked that.