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
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!
super simple and easy to follow, thank you!
Great video and very informative 👍
@SupeRails
2 жыл бұрын
Glad you liked it!
Superb, thank you!!!
I suggest you to keep making these kind of helpful video on youtube also
@SupeRails
3 жыл бұрын
I will try my best
Amazing video
@SupeRails
2 жыл бұрын
Hello Deepak! Thank you!
Usefull video thanks yashmaro i also have your udemy course 25+ gems and i am learning ROR from them.
@SupeRails
3 жыл бұрын
Nice to see you here too, Sunny!
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)
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
How does has_one_attached :avatar work without an avatar.rb model?
Please do a video on Rails Notifications!
How do you replace a specific image when you use has_many_attached?
@SupeRails
3 жыл бұрын
Good question! If you use file_field, new images replace old ones... Gotta think about that
@SupeRails
3 жыл бұрын
Here's how you DELETE a specific image when you use has_many_attached: kzread.info/dash/bejne/g5eVtcasiNfKptI.html
@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
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
Жыл бұрын
You must be doing something else wrong because this is what I do and it works perfectly.
@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.