This approach sets Active Storage apart from the competition. active_storage_blobs does not put the binary into a database, but tracks its location, along with information on file’s size, content type, and metadata. Blob models store attachment metadata (filename, content-type, etc.), and their identifier key in the storage service.”īlob stands for “binary large object”, as our attachments are, in essence, large binary files. “Active Storage uses polymorphic associations via the Attachment join model, which then connects to the actual Blob. Here is what they do, according to framework’s README: Once executed, it creates two tables that Active Storage needs to deliver on its promises: active_storage_attachments and active_storage_blobs. With things attachedĭisclaimer: we will not go into comparing Active Storage with existing solutions, be it CarrierWave, Paperclip or Shrine, but rather try to make a beginner-friendly introduction to the framework as we get to know it ourselves.Įnabling Active Storage in your application starts with a Rake task: running rails active_storage:install in the command line will add a new migration to your db/migrate folder. We will talk about Active Storage first, and then, if you bear with us till the end of this guide, we will go into other Rails 5.2 features. According to DHH, Active Storage was extracted from Basecamp 3, so it claims to be a framework “born from production”. For the first time in Rails history, we get a built-in solution for handling file uploads in our projects. Out of all new shiny things that the last major update before Rails 6 brings, Active Storage stands out the most. So we might as well start unwrapping! You can install Rails 5.2 today by running gem install rails -prerelease. New ways to handle file uploads, share credentials with your team, set up Content Security Policy, even start your application-we are looking at what’s new in Rails 5.2 and focus on Active Storage with a step-by-step introduction to the new framework.Įven though we did not get it as a promised New Year present and were just told to wait another month for the official release, Rails 5.2 was assigned RC1 status and is now considered stable.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |