{"id":14955500,"url":"https://github.com/medicinal-ruby/active_storage_demo","last_synced_at":"2026-01-19T22:31:55.499Z","repository":{"id":93321662,"uuid":"312370226","full_name":"medicinal-ruby/active_storage_demo","owner":"medicinal-ruby","description":"An ActiveStorage demo for S3 uploads + local disk. It's better than the paperclip gem, by far.. ","archived":false,"fork":false,"pushed_at":"2020-11-26T19:19:21.000Z","size":161,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-07T09:46:33.330Z","etag":null,"topics":["activestorage","guide","helpers","rails","rails5","rails6","tutorial","tutorials"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/medicinal-ruby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-12T19:02:38.000Z","updated_at":"2022-12-24T05:29:40.000Z","dependencies_parsed_at":"2023-04-28T14:01:18.243Z","dependency_job_id":null,"html_url":"https://github.com/medicinal-ruby/active_storage_demo","commit_stats":{"total_commits":6,"total_committers":2,"mean_commits":3.0,"dds":"0.16666666666666663","last_synced_commit":"7e6ab857ad0fa19e3e68b29c59391615d57e5f6b"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/medicinal-ruby/active_storage_demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/medicinal-ruby%2Factive_storage_demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/medicinal-ruby%2Factive_storage_demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/medicinal-ruby%2Factive_storage_demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/medicinal-ruby%2Factive_storage_demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/medicinal-ruby","download_url":"https://codeload.github.com/medicinal-ruby/active_storage_demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/medicinal-ruby%2Factive_storage_demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28587241,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T20:45:59.482Z","status":"ssl_error","status_checked_at":"2026-01-19T20:45:41.500Z","response_time":67,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activestorage","guide","helpers","rails","rails5","rails6","tutorial","tutorials"],"created_at":"2024-09-24T13:11:14.638Z","updated_at":"2026-01-19T22:31:55.482Z","avatar_url":"https://github.com/medicinal-ruby.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Active Storage Overview [![Generic badge](https://img.shields.io/badge/EASY-YES-FF00FF.svg)](https://shields.io/)\n\n\n## What is Active Storage?\nActive storage is an easy, built-in rails service that provides integration to your local disk and popular services like S3, Azure and Google Cloud.\n\n## Setup \nMake sure you have Rails 5.2 (AT LEAST!) before starting. Run the command: \u003cbr\u003e\n```ruby\nbin/rails active_storage:install \u0026\u0026 bin/rails db:migrate\n```\nNavigate to ```config/storage.yml``` and confirm the yml file replicates this one:\n\n```yml\n#config/storage.yml\n\nlocal:\n  service: Disk\n  root: \u003c%= Rails.root.join(\"storage\") %\u003e\n\ntest:\n  service: Disk\n  root: \u003c%= Rails.root.join(\"tmp/storage\") %\u003e\n\namazon:\n  service: S3\n  access_key_id: \"\"\n  secret_access_key: \"\"\n  bucket: \"\"\n  region: \"\" # e.g. 'us-east-1'\n```\nThis tutorial, we will be using the disk locally for some image uploads. Double check your development enviorment that we are writing to our local disk:\n\n```ruby\n# config/environments/development.rb\n\nconfig.active_storage.service = :local\n```\n\nWe can now scaffold our Photo resource to create an upload form to test Active Storage!\n\u003cbr\u003e\u003cbr\u003e\n\n```ruby\nrails g scaffold Photo description:text \n```\nthen run the db migrations \n```ruby\nrails db:migrate\n```\n## Active Storage \n\nThe important thing is to add the ```has_one_attached :image``` association in the Photo model. \n\nThen add the file_upload element to the scaffolded form:\n```ruby\n  \u003cdiv class=\"field\"\u003e\n    \u003c%= f.label :image %\u003e\n    \u003c%= f.file_field :image %\u003e\n  \u003c/div\u003e\n  ```\n  \n \n Also, add the photo to show up in the show.html.erb file\n ```\n \u003c%= image_tag event.image %\u003e\n ```\n \n Finally, add image to the permitted params in the photo controller\n ```ruby\n def photo_params\n  params.require(:photo).permit(:description, :image)\n end\n   ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmedicinal-ruby%2Factive_storage_demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmedicinal-ruby%2Factive_storage_demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmedicinal-ruby%2Factive_storage_demo/lists"}