ruby-on-railsdragonfly-gem

trying to uploade with dragonfly gem. it uploads the first file but after that I can't upload or edit my post until I refresh the page


I followed this https://www.youtube.com/watch?v=gp_kn6afl-Y and it will let me upload but wont let me edit or upload another image.

in _form.html.erb I have

<div class="form-group"></div>
<%= f.label :asset %>
<%= f.file_field :asset %>
<% if f.object.asset_stored? %>
  <%= image_tag f.object.asset.thumb('140x140').url, class: 'img-thumbnail' %>
  <em>Current image</em>
<% end %>
</div>

<div class="actions">
 <%= f.submit "Save", class: "btn btn-default" %>
</div>
<% end %>

and in dragonfly_images_controller.rb I have

def dragonfly_image_params
  params.require(:dragonfly_image).permit(:asset)
end

not exactly sure why it wont let me save a new or edit an existing until after I hit refresh on my browser. could it be something in the controller that is only allowing it to update after I visited the page and hit refresh?


Solution

  • It was a turbolinks issue. I added this line below

     <%= link_to ..... { no_turbolink: true } .... %>
    

    to link_to and it worked!