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.

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>