1

Using Rails 4.2.4

I generated a scaffold in rails to test out filepicker. Everything seems to be working well except when I hit refresh on the page that has the file picker button, 3 buttons display on the page instead of the original 1. This happens on both Safari and Chrome. Can anyone tell me how to fix this?

When the page first loads, one button:

One Button

On refresh:

enter image description here

application.html.erb source:

<!DOCTYPE html>
<html>
<head>
  <title>FilepickerTest</title>
  <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
  <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
  <%= csrf_meta_tags %>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
</head>
<body>

<%= filepicker_js_include_tag %>
<%= yield %>

</body>
</html>

_form.html.erb source:

...
<div class="field">
  <%= f.label :filepicker_url %><br>
  <%= f.filepicker_field :filepicker_url, :button_text => "Select Image", :button_class => "btn btn-default", :onchange => 'onImageUpload(event)' %>
</div>
<div class="actions">
  <%= f.submit 'Upload Image' %>
</div>
...
Tommy J
  • 421
  • 2
  • 5
  • 18

1 Answers1

0

The problem was related to turbolinks and was fixed by removing the javascript call in the application.html.erb file.

Tommy J
  • 421
  • 2
  • 5
  • 18