app/controllers/spina/admin/photos_controller.rb in spina-0.10.0 vs app/controllers/spina/admin/photos_controller.rb in spina-0.11.0
- old
+ new
@@ -16,18 +16,29 @@
def media_library
redirect_to spina.admin_photos_path
end
def create
- @photo = Photo.create!(photo_params)
- respond_to do |format|
- format.js do
- render params[:media_library] ? :create : :create_and_select
+ if photo_params[:files].present?
+ @photos = photo_params[:files].map do |file|
+ Photo.create!(file: file)
end
- format.json do
- render json: { file_url: @photo.file_url }
+ respond_to do |format|
+ format.js do
+ render :create_multiple
+ end
end
+ else
+ @photo = Photo.create!(photo_params)
+ respond_to do |format|
+ format.js do
+ render params[:media_library] ? :create : :create_and_select
+ end
+ format.json do
+ render json: { file_url: @photo.file_url }
+ end
+ end
end
end
def destroy
@photo = Photo.find(params[:id])
@@ -98,10 +109,10 @@
def set_breadcrumbs
add_breadcrumb I18n.t('spina.website.media_library'), spina.admin_media_library_path
end
def photo_params
- params.require(:photo).permit(:file)
+ params.require(:photo).permit(:file, files: [])
end
end
end
end