gateway/app/controllers/cms/image_controller.rb

34 lines
632 B
Ruby
Raw Normal View History

2022-11-24 14:44:31 +01:00
module Cms
2022-11-25 12:10:11 +01:00
class ImageController < CmsController
2022-11-24 14:44:31 +01:00
@@root = "app/assets/images/cms/"
2022-11-24 21:28:56 +01:00
@@files = Set.new Dir.new(Rails.root + @@root).children
2022-11-24 14:44:31 +01:00
def index
@files = files
end
2022-11-24 21:28:56 +01: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 14:44:31 +01:00
private
def files
@@files
end
end
end