Programmable Media

Ruby/Rails quick start

Last updated: Oct-30-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.

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)

5. Run your code

In your Ruby IDE or in a terminal (from the /scripts folder of your project), run your quickstart.rb script and take a look at the output you get from each step of this quick start:

View the completed code

You can find the full code example for this quick start on GitHub.

Next steps

  • Learn more about the Ruby/Rails SDK by visiting the other pages in this SDK guide.
  • Get comprehensive details about Cloudinary features and capabilities:
Cloudinary Academy

 

Check out our Introduction to Cloudinary for Ruby Developers course in the Cloudinary Academy. This self-paced resource provides video-based lessons, sample scripts and other learning material to get you going with Ruby and Cloudinary today.

✔️ Feedback sent!

Rate this page: