API Image Uploads With Active Storage And React In Ruby On Rails 7

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

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

  • @Deanin
    @Deanin  2 года назад +13

    Hopefully this is helpful! I've seen this request a few times but never sat down to really try and solve it. I feel a bit more comfortable with APIs now so this ended up being not too bad.

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

      suggestion is to go with redux and toolkit next time... is quite a thing using rails api + react/redux

  • @mykovasyl
    @mykovasyl Год назад +4

    Let me just say, using ActiveStorage to give my users an avatar has been my entire goal for my final project at bootcamp. I spent countless hours on it, countless. Nothing worked. The docs on ActiveStorage didn't give the full picture, everyone else was using devise and other languages and gems and yadda yadda...nothing worked for my situation. I then spent another 7 hours trying to get it to work with the help of a software engineer friend. It all seemed hopeless. Then, I found your video. In one hour, I had an avatar staring back at me on the profile page. My eyes almost filled with tears at the joy I felt (and if you ask my wife, I don't have emotions). You sir are my hero. You have given me release from this nightmare. I can finally step out into the sunlight (tomorrow morning) and breath easy. Thank you, thank you, thank you so so much!

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

      I'm in tears reading this, both from laughter and from relatability when I first had to crawl through this mess to figure it out. I'm glad it helped, and thank you for making my night with this comment!

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

      @@Deanin I would love to see a video on attaching multiple files, attaching PDFs and JPEGs for another user to download. So a tutor would upload several files/worksheets and the student would be able to click the link to preview and then download the files. Please let me know when you make one! Thank you! :)

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

      Just wanted to stop by and say I recorded something similar. It covers how to upload multiple images/files from an API and displays them.
      At that point, you'd just have to create the preview link and download functionality, but you're at least storing/retrieving multiple attachments. Should be up in a few hours!

  • @iliatalebzade8751
    @iliatalebzade8751 2 года назад +3

    Please, Please, Please
    don't stop making videos man
    you're one of the few creators that do rails tuts at this level of comprehensiveness, if not the only one

    • @Deanin
      @Deanin  2 года назад +2

      I'm trying to keep them up haha. I'm really glad they're helpful!

  • @beacoder
    @beacoder 2 года назад +5

    yassss! another option to consider other than `includes` / serializers could be `methods`, so render json: @product, includes: [:desc, :created_at], methods: [:image_url]

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

      Thx! you save my life! In this example, you only need to show 1 image, but when I need to do a .all render json: CategorySerializer.new doesn't work to me

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

      Thank you for this comment! This was the solution for me using .all

  • @s.bamahfoodh
    @s.bamahfoodh Год назад +1

    Thank you so much, I am stuck with this image uploading thing for so long. Following your tutorial saved my life. Like, Subscribe and a big Share

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

      I'm just glad it worked for you! 🙂

  • @aanmeba
    @aanmeba 2 года назад +3

    literally you saved me! Thank you so much! I was suffering to figure out "missing params" error. Thank you so much!

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

      Glad it helped!

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

    Thanks!

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

      Thank you! 🙂

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

    Thank you so much. The JSON API Serializer saved the day. Great tutorial, subscribed.

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

      Glad it helped! And yeah, that JSON serializer was a cool find haha

  • @alexis-xj4rc
    @alexis-xj4rc 2 года назад +1

    true this one was really needed also hopefully you gonna hit on nextJS with typescript

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

    excellent, i managed to make it work on prod with aws sdk, and also update the post image.
    thanks !

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

    I love you, sorry, that was precisely what I needed lol

  • @StatusKing-xp2xu
    @StatusKing-xp2xu Год назад

    Salute you man 👍🏻👍🏻

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

    Merci beaucoup. Sois béni :D

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

    This was extremely helpful! Wondering if you have any advice on retrieving image urls from the relational data included in the fetch? For example, fetching an instance of a Post along with the user who made said post and tying to get the url for the avatar of that user.
    Looking forward to viewing more of your videos!

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

    incredible!

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

    thanks for a lot

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

    which vs code extension do you use for the autofill suggestions , ex. post request at 11:21 ?

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

      I think the two extensions I use for that are TabNine and GitHub CoPilot

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

      @@Deanin thank you

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

    hi can i use has_many_attached and if the answer is yes how to do that,
    thanks

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

    Update:
    Change "jsx": "react" => "jsx": "react-jsx" in jsconfig.json
    if you got error:
    'React' refers to a UMD global, but the current file is a module

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

    🤣🤣 40years later thank God we now have vite