Get a javascript value to a ruby value

95 views Asked by At

I am trying to use Aviary API in my ruby on rails site. I have trouble to get back the URL created by Aviary in the onSave function. I don't know how to access it in ruby. Do you have an idea? The variable i would like to have in ruby is newURL

    <% if @photo.image? %>

    <!-- Load widget code -->
<script language="JavaScript" type="text/javascript" src="https://dme0ih8comzn4.cloudfront.net/js/feather.js"></script>


<!-- Instantiate the widget -->
<script type="text/javascript">

    var featherEditor = new Aviary.Feather({
        apiKey: '  f20374413e3ff5a8',
        apiVersion: 2,
        theme: 'light',
        tools: 'all',
        appendTo: '',
        fileFormat: 'jpg',
        onSave: function(imageID, newURL) {
            var img = document.getElementById(imageID);
            img.src = newURL;
        },
    });

    function launchEditor(id, src) {
        featherEditor.launch({
            image: id,
            url: src
        });
       return false;
    }

</script>                         

<!-- Add an edit button, passing the HTML id of the image and the public URL to the image -->
<a href="#" data-refresh="true" onclick="return launchEditor('editimage1', 
    '<%= @photo.image.url %>');">Edit!</a>

<img id='editimage1' src='<%= @photo.image.url %>' height="352" width="470"/>


  <% end %>
0

There are 0 answers