Ruby on Rails #20 ActiveStorage - attach avatar, attach images

Source code:
github.com/corsego/20-active_...
Docs:
edgeguides.rubyonrails.org/ac...
install active_storage, post has one avatar:
github.com/corsego/20-active_...
post has many images:
github.com/corsego/20-active_...
0:00 The Problem
1:12 Install ActiveStorage
1:56 Has One Attached
4:30 Where are files stored?
06:00 Displaying images
08:19 Summary 1
09:59 Editing=Replacing Attachments
10:17 Has Many Attached
15:04 Next Steps

Пікірлер: 22

  • @Ogarocious_dance
    @Ogarocious_dance2 жыл бұрын

    THANK YOU! THANK YOU! THANK YOU! I'm building my first app and I was figuring out the best way to handle this instead of using image URLs!

  • @Giulyozz
    @Giulyozz Жыл бұрын

    super simple and easy to follow, thank you!

  • @aniketjoshi8043
    @aniketjoshi80432 жыл бұрын

    Great video and very informative 👍

  • @SupeRails

    @SupeRails

    2 жыл бұрын

    Glad you liked it!

  • @jaydippansuriya5003
    @jaydippansuriya5003 Жыл бұрын

    Superb, thank you!!!

  • @sunnygond7227
    @sunnygond72273 жыл бұрын

    I suggest you to keep making these kind of helpful video on youtube also

  • @SupeRails

    @SupeRails

    3 жыл бұрын

    I will try my best

  • @Deepaksingh-ee8zp
    @Deepaksingh-ee8zp2 жыл бұрын

    Amazing video

  • @SupeRails

    @SupeRails

    2 жыл бұрын

    Hello Deepak! Thank you!

  • @sunnygond7227
    @sunnygond72273 жыл бұрын

    Usefull video thanks yashmaro i also have your udemy course 25+ gems and i am learning ROR from them.

  • @SupeRails

    @SupeRails

    3 жыл бұрын

    Nice to see you here too, Sunny!

  • @kwhandy
    @kwhandy2 жыл бұрын

    just a suggestion, maybe it should be good if you can share tutorial how to use activestorage with upload ui library like Filepond or Uppy with hotwire for your next video 🏓 (since we all start using hotwire/turbo these days)

  • @jemimahchepyego5447
    @jemimahchepyego5447 Жыл бұрын

    How can i implement this i want to upload many pictures but only display the first image , the other images are displayed when clicked by user

  • @fugeeohu9357
    @fugeeohu9357 Жыл бұрын

    How does has_one_attached :avatar work without an avatar.rb model?

  • @samarthgwalani5585
    @samarthgwalani5585 Жыл бұрын

    Please do a video on Rails Notifications!

  • @hemrodamartin4388
    @hemrodamartin43883 жыл бұрын

    How do you replace a specific image when you use has_many_attached?

  • @SupeRails

    @SupeRails

    3 жыл бұрын

    Good question! If you use file_field, new images replace old ones... Gotta think about that

  • @SupeRails

    @SupeRails

    3 жыл бұрын

    Here's how you DELETE a specific image when you use has_many_attached: kzread.info/dash/bejne/g5eVtcasiNfKptI.html

  • @SupeRails

    @SupeRails

    3 жыл бұрын

    add this to your application.rb to not replace initially attached files by new ones: config.active_storage.replace_on_assign_to_many = false source: stackoverflow.com/a/58295158/5695646

  • @SS-li3ft
    @SS-li3ft2 жыл бұрын

    how can we add multiple images without replacing existing images? I tried config.active_storage.replace_on_assign_to_many = false in application.rb , but still it replacing the existing images. Is there any other way to do it on rails 7 applications??

  • @AlainPilon

    @AlainPilon

    Жыл бұрын

    You must be doing something else wrong because this is what I do and it works perfectly.

  • @SS-li3ft

    @SS-li3ft

    Жыл бұрын

    If you want to update only some fields, then you need to pass only params of that fields. otherwise if the data is not present it will pass as nil.