I am using an active administrator with a carrier wave. I am encountering a problem downloading an image using an active admin. I already have an image in my folder public/imgnamed banner.png. Now I want to override this image with another image through the admin panel. When I upload the image, it shows me the options as shown below:
Parameters: {"utf8"=>"✓", "authenticity_token"=>"iHI02QCklnooY2WvKOAI/OUPi6phmvVsYnXuRzvXg2Q=", "home_banner"=>{"home_banner_image"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0xd8f728c @original_filename="Penguins.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"home_banner[home_banner_image][image]\"; filename=\"Penguins.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/tmp/RackMultipart20140612-18313-18qw3aj>>}}, "commit"=>"Update Home banner", "id"=>"539981982131fc9c0e000002"}
But it does not save the image in the database.
Here is my model and bootloader
model: -
class Banner
include Mongoid::Document
include Mongoid::Timestamps::Created
include Rails.application.routes.url_helpers
field :banner_image, type: String
mount_uploader :banner_image, BannerUploader
end
Uploader: -
require 'open-uri'
require "digest/md5"
require 'carrierwave/processing/mini_magick'
class BannerUploader < CarrierWave::Uploader::Base
storage :file
def store_dir
"/public/img"
end
def extension_white_list
%w(jpg jpeg gif png)
end
def filename
"banner.png" if original_filename
end
end
And my activeadmin for admin folder: -
ActiveAdmin.register Banner do
index do
column :banner_image
default_actions
end
form(:html => { :multipart => true }) do |f|
f.inputs "Banner Image" do
f.semantic_fields_for :banner_image do |fi|
fi.input :image, :as => :file
end
end
f.buttons
end
end
I am using mongoDb, and my requirement is that I already have the image in the / img public folder to update it via admin so that it automatically reflects on the front side without changing the view code.
, .
.