By carrierwave, you can either upload file/picture from your machine directly by <%= f.file_field :image %>
, or from the link on remote server using helper method 'remote_image_url' . This naming convention remote_yourimagefield_url
is important, as carrierwave will come to know by this naming structure to grab files from the remote server. As :remote_image_url points to the same column as :image, therefore they are stored in the same column
CarrierWave Uploading Using SimpleForm; Why do "remote_image_url" and "image" save to same database column?
-
01-07-2023 - |
Domanda
I have a simple_form with an image uploader, which is connected to CarrierWave:
<%= simple_form_for @house do |f| %>
<%= f.input :price %>
<%= f.input :town %>
<%= f.input :description %>
<%= f.input :bedrooms %>
<%= f.input :bathrooms %>
<%= f.input :url, label: "URL" %>
<%= f.input :rating %>
<%= f.input :remote_image_url %>
<%= f.file_field :image %>
<%= f.button :submit, "Add House" %>
<% end %>
For some reason the two fields
<%= f.input :remote_image_url %>
<%= f.file_field :image %>
are storing to the exact same column in my database, which is named "image". I don't understand why.
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow