Programmable Media

Ruby/Rails quick start

Last updated: Jun-04-2024

This quick start lets you get an end-to-end implementation up and running using the Ruby/Rails SDK in 5 minutes or less.

Notes
  • This quick start is designed for quick onboarding. It doesn't necessarily employ coding best practices and the code you create here isn't intended for production.
  • If you aren't familiar with Cloudinary, you may want to first take a look at the Developer Kickstart for a hands-on, step-by-step introduction to Programmable Media features.

    You may also find our Glossary helpful to understand Cloudinary-specific terminology.

1. Set up and configure the SDK

Install the SDK

In a terminal, in your Ruby environment, run:

Configure Cloudinary

In your project, create a new file called config.rb with the code below. Make sure to update it to use your product environment's credentials:

config.rb

Important
When writing your own applications, follow your organization's policy on storing secrets and don't expose your API secret.

Reference the configuration from a ruby script

In your project, create a new file called quickstart.rb.

For the sake of this quick start, you'll put all the Cloudinary code other than the configuration in this single file and only run it at the end.

To reference your product environment configuration from this new file, add:

quickstart.rb

2. Upload files

To upload some remote files to Cloudinary, paste the following to the end of your quickstart.rb file:

quickstart.rb (continued)

3. Get and use details of an image

Paste these two snippets to perform some management operations on the assets you previously uploaded:

Return details of an existing resource

quickstart.rb (continued)

Retrieve and update specific attributes of an asset

quickstart.rb (continued)

4. Transform images

Add this code to your file in order to generate a few different transformation URLs on the two assets you previously uploaded:

quickstart.rb (continued)

Tip