Multiple image upload finished
This commit is contained in:
@@ -47,15 +47,13 @@ class Settings::ShopsController < ApplicationController
|
|||||||
# PATCH/PUT /settings/shops/1
|
# PATCH/PUT /settings/shops/1
|
||||||
# PATCH/PUT /settings/shops/1.json
|
# PATCH/PUT /settings/shops/1.json
|
||||||
def update
|
def update
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @settings_shop.update(shop_params)
|
if @settings_shop.update(shop_params)
|
||||||
if params[:display_images].present?
|
if params[:display_images].present?
|
||||||
params[:display_images]['image'].each do |a|
|
params[:display_images][:image].each do |a|
|
||||||
|
@aa = Base64.encode64(a.read)
|
||||||
aa = a.read
|
@display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :image => "data:image/jpeg;base64,"+@aa)
|
||||||
base64_encoded = Base64.encode64(aa)
|
|
||||||
byebug
|
|
||||||
@display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :image => base64_encoded)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
format.html { redirect_to settings_shops_url, notice: 'Shop was successfully updated.' }
|
format.html { redirect_to settings_shops_url, notice: 'Shop was successfully updated.' }
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class DisplayImage < ApplicationRecord
|
class DisplayImage < ApplicationRecord
|
||||||
mount_uploader :image, DisplayImageUploader
|
#mount_uploader :image, DisplayImageUploader
|
||||||
belongs_to :shop
|
belongs_to :shop
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -44,25 +44,14 @@
|
|||||||
<div class="panel padding-10">
|
<div class="panel padding-10">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="menu-item-img">
|
<div class="menu-item-img">
|
||||||
|
|
||||||
<%= f.fields_for :display_images do |p| %>
|
<%= f.fields_for :display_images do |p| %>
|
||||||
<div class="field">
|
<%= image_tag "#{p.object.image}", :class => "img-thumbnail" %>
|
||||||
<%= image_tag p.object.image, :class => "img-thumbnail" %>
|
<%= link_to "Destroy", settings_shop_display_image_path(p.object), method: :delete %>
|
||||||
|
<% end %>
|
||||||
<%= link_to "Destroy", settings_shop_display_image_path(p.object), method: :delete %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<%= f.file_field :image, :multiple => true, name: "display_images[image][]" %>
|
<%= f.file_field :image, :multiple => true, name: "display_images[image][]" %>
|
||||||
<!-- <%= f.fields_for :display_images do |p| %>
|
|
||||||
<div class="field">
|
|
||||||
<%= p.label :image %><br>
|
|
||||||
<%= p.file_field :image, :multiple => true, name: "display_images[image][]" %>
|
|
||||||
</div>
|
|
||||||
<% end %> -->
|
|
||||||
|
|
||||||
<div class="form-actions p-l-15">
|
<div class="form-actions p-l-15">
|
||||||
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
|
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
|
||||||
|
|||||||
@@ -103,7 +103,7 @@
|
|||||||
<td style="width:20%">Shop Images</td>
|
<td style="width:20%">Shop Images</td>
|
||||||
<td>
|
<td>
|
||||||
<% @display_images.each do |p| %>
|
<% @display_images.each do |p| %>
|
||||||
<%= image_tag p.image , :size => '200x200'%><br>
|
<%= image_tag "#{p.image}" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user