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
- 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' ...
- 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 ...
- 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', }) } ...
- Now, put a
<div/>
element in the view... <div id="pesdk" style="width: 1024px; height: 768px;"> ...