npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

activestorage-cloudinary

v1.0.0-beta

Published

Attach Cloudinary files in Rails applications

Readme

ActiveStorage::Service::CloudinaryService

With v5.2, Rails introduces ActiveStorage, to facilitate uploading files to cloud services and attaching those files to ActiveRecord objects. Out of the box, it comes with implementations for cloud storage services; Amazon S3, Google Cloud Storage, and Microsoft Azure Storage; with an extendible adapter for adding support for other storage services.

This gem extends the ActiveStorage::Service api with an implementation for Cloudinary cloud service. The implementation is a thin wrapper around the official cloudinary gem to provide necessary interfaces required to hook up cloudinary to the active_storage api. Serving as a middleman, it interprets active_storage requests and delegate to their cloudinary gem contemporary and parses the response as necessary. So you can work with Cloudinary much like you would any of the other active_storage services that comes out of the box.

Installation

Add this line to your application's Gemfile:

gem 'activestorage-cloudinary-service'

And then execute:

$ bundle

Usage

In your Rails 5.2+ app, run:

  rails active_storage:install

This copies over the active_storage migration for creating the needed tables and then run:

  rails db:migrate

Note: you can skip the above two steps if you already have active_storage setup or if working a new Rails 5.2 (the setup is automatically added)

Declare a Cloudinary service in config/storage.yml. Each active_storage service requires a name and the relevant configurations options. Basic configuration options for cloudinary are cloud_name, api_key and api_secret. These are available from your cloudinary account dashboard.

cloudinary:
  service: Cloudinary
  cloud_name: <%= ENV['CLOUDINARY_CLOUD_NAME'] %>
  api_key:    <%= ENV['CLOUDINARY_API_KEY'] %>
  api_secret: <%= ENV['CLOUDINARY_API_SECRET'] %>

If using the CLOUDINARY_URL env var, extract the needed information from the URL.

<% config = URI.parse ENV.fetch("CLOUDINARY_URL") %>
cloudinary:
  service: Cloudinary
  cloud_name: <%= config.host %>
  api_key: <%= config.user %>
  api_secret: <%= config.password %>

The env vars should correspond to their appropriate values as defined in your app. Or using rails credentials:edit to set the cloudinary secrets (as cloudinary:cloud_name|api_key|api_secret)

cloudinary:
  service: Cloudinary
  cloud_name: <%= Rails.application.credentials.dig(:cloudinary, :cloud_name) %>
  api_key: <%= Rails.application.credentials.dig(:cloudinary, :api_key) %>
  api_secret: <%= Rails.application.credentials.dig(:cloudinary, :api_secret) %>

See here for other supported configurations options that can be provided.

Tell Active Storage to use the Cloudinary service by setting Rails.application.config.active_storage.service. It is recommended to do this on a per-environment basis to enjoy the flexibility of using different services for different environment.

For example, to use the cloudinary service in the production environment, you would add the following to config/environments/production.rb

config.active_storage.service = :cloudinary

Known issues

Currently, active_storage client-side upload doesn't work with Cloudinary. This because the cloudinary api doesn't, as at now, support the PUT request method used by activestorage.js library and as such client side uploads will error out with the message Method PUT is not allowed by Access-Control-Allow-Methods in preflight response.

Nevertheless, the necessary ground work for this is set and once either active_storage is updated to support more request type or Cloudinary enables support for PUT request method, it should work fine.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/0sc/activestorage-cloudinary-service. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the ActiveStorage::Service::CloudinaryService project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.