Skip to main content

Ruby Gem

Learn how to get started with the PhotoEditor SDK for Web and Ruby on Rails and how to swiftly integrate the SDK into a Ruby on Rails project.

Logo

Getting Started with our Ruby Gem

We created a Ruby gem for easily integrating the PhotoEditor SDK for Web in any Ruby on Rails project. Just follow the steps and you'll get a fully fledged photo editor in your rails app.

Free Trial#

Our tech is modified to be used for testing purposes without a license key. To start testing just follow this Get Started guide and leave out the step of entering the commercial license keys. The editor will simply render a watermark over the preview and final results. And in case you need any technical assistance, make sure to reach out to us: https://img.ly/support. We’ll be glad to help.

WARNING: The repository is not meant as a fully fledged Ruby Gem, but as a base for further development instead.

Setup the Rails asset pipeline#

  1. Reference Gem in your bundlers Gemfile. Open your Gemfile and insert

    ...
    gem 'pesdk-html5-rails', :git => 'https://github.com/imgly/pesdk-ruby-gem-demo.git'
    ...
  2. Register javascript with the Rails asset pipeline. Open /assets/javascripts/application.js and insert the following lines

    ...
    //= require react.production.min
    //= require react-dom.production.min
    //= require react-dom-server.browser.production.min
    //= require styled-components.min
    //= require photoeditorsdk
    ...
  3. Create a custom javascript file or modify your application.js to initialize the PhotoEditor UI on window load as follows

    ...
    window.onload = function () {
      PhotoEditorSDK.PhotoEditorSDKUI.init({
          container: '#pesdk',
          license: '', // <- replace this with the content of your license file. The JSON-object needs to be in string format
          image: '', // <- Image url or Image path relative to assets folder
          assetBaseUrl: '/assets',
      })
    }
    ...
  4. Now, put a <div/> element in the view

    ...
    <div id="pesdk" style="width: 1024px; height: 768px;">...</div>