Ruby/Rails quick start
Last updated: Mar-09-2023
This quick start is intended to let you quickly try using several common Cloudinary features. It doesn't necessarily employ coding best practices and the code you create here isn't intended for production.
You can perform this quick start in a code sandbox or in a clean project in the dev environment of your choice.
You can also view the completed code of this quick start in a GitHub repo.
This quick start can be performed using any Ruby framework or environment.
You may also find our Glossary helpful to understand Cloudinary-specific terminology.
Prerequisites
To perform the steps in this quick start, you'll need:
- A Cloudinary account. If you don't have one yet, you can quickly register for free.
- Your product environment credentials. You can find your credentials in the Dashboard page of your Cloudinary Console.
- A working Ruby/Rails development environment with a supported version of Ruby/Rails.
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.
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:
2. Upload files
To upload some remote files to Cloudinary, paste the following to the end of your quickstart.rb
file:
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
Retrieve and update specific attributes of an asset
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:
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:
- Media upload guide: Provides details and examples of the upload options.
- Image transformations guide: Provides details and examples of the transformations you can apply to image assets.
- Video transformations guide: Provides details and examples of the transformations you can apply to video assets.
- Transformation URL API Reference: Provides details and examples of all available transformation parameters.
- Admin API guide: Provides details and examples of the methods available for managing and organizing your media assets.