Logo

Getting Started with our Ruby Gem

We created a Ruby gem for easily integrating the PhotoEditor SDK for HTML5 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
     //= require react-dom
     //= require PhotoEditorSDK.min
     //= require PhotoEditorReactUI.min
     ...
    
  3. Register stylesheets with the Rails asset pipeline. Open /assets/stylesheets/application.css and insert the following lines
     ...
     *= require PhotoEditorReactUI
     ...
    

    ### Initialize the editor Create a custom javascript file or modify your application.js to initialize the PhotoEditor UI on window load as follows

     ...
    
     window.onload = function () {
       var apiKey = 'your-api-key', // <-- Please replace this with your API key
    
       var container = document.getElementById('pesdk')  
       var editor = new PhotoEditorSDK.UI.ReactUI({
         container: container,
         apiKey: apiKey,
         assets: {
             baseUrl: '/assets', 
             resolver: function (path) { return path }
         }
       })
     }
     ...
    
    

    Now, put a <div/> element in the view

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