简体   繁体   中英

Rails - paperclip not uploading any images

I've installed paperclip gem for my Rails project. Everything seems to be working, I am getting no errors but when im trying to upload the picture for my record - as soon as I click the submit button the page just refreshes and the image doesn't get uploaded.

Here is the line with the file field:

<%= form_for @wiki_edytowany, url: {action: "wiki_aktualizuj", id: @wiki_edytowany.id} do |b| %>
<table class="table table-bordered">
    <tr>
      <td>Ikona</td>
      <td><%= b.file_field :ikona %></td>
    </tr>
    <tr>
       <td></td>
       <td><%= b.submit "Edytuj", class: 'btn btn-success' %> &nbsp;&nbsp;&nbsp;&nbsp; <%= link_to "Anuluj", ('wiki_devtest'), class: "btn btn-success" %></td>
    </tr>
</table>
<% end %>

My model:

class Items < ActiveRecord::Base

  has_attached_file :ikona, styles: { :medium => "128x128>", :thumb => "32x32>" }

end

Any my controller params for it:

def przedmiotyparams
    params.require(:przedmioty).permit(:nazwa, :typ, :waga, :rzadkosc, :uzywalne, :obrazenia, :miejsce, :magazynek, :obrona, :glod, :pragnienie, :efekt, :zakazenie, :zasieg, :szybkosc, :opis, :ciekawostki, :ikona, :wersja)
  end

If anyone does know the solution - please help. Thanks in advance!

Okay so I corrected the path and it seems to work. Anyway, thanks for your response.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM