gateway/app/controllers/cms/images_controller.rb

34 lines
633 B
Ruby
Raw Normal View History

2022-11-24 15:44:31 +02:00
module Cms
2022-11-25 14:46:49 +02:00
class ImagesController < CmsController
2022-11-24 15:44:31 +02:00
@@root = "app/assets/images/cms/"
2022-11-24 22:28:56 +02:00
@@files = Set.new Dir.new(Rails.root + @@root).children
2022-11-24 15:44:31 +02:00
def index
@files = files
end
2022-11-24 22:28:56 +02:00
def new
end
def create
io = params['image_file']
ending = io.original_filename.split("/").last.split(".").last
filename = params['filename'] + "." + ending
File.open(Rails.root.join('app/assets/images/cms', filename), "wb") do |f|
f.write io.read
end
@@files << filename
redirect_to cms_image_index_path
end
2022-11-24 15:44:31 +02:00
private
def files
@@files
end
end
end