finish image selection on section, polish image index
This commit is contained in:
@ -6,14 +6,15 @@ module Cms
|
||||
|
||||
@@images = {}
|
||||
|
||||
attr_reader :name , :type , :created_at , :updated_at
|
||||
attr_reader :name , :type , :size , :created_at , :updated_at
|
||||
|
||||
def initialize(filename)
|
||||
puts filename
|
||||
puts "New Image #{filename}"
|
||||
@name , @type = filename.split(".")
|
||||
file = File.new(Rails.root.join(Image.root,filename))
|
||||
@created_at = file.birthtime
|
||||
@updated_at = file.ctime
|
||||
@size = (file.size/1024).to_i
|
||||
end
|
||||
|
||||
def self.all
|
||||
@ -27,7 +28,8 @@ module Cms
|
||||
|
||||
#save an io with given name (without ending, that is taken from io)
|
||||
def self.create_new(filename , io)
|
||||
ending = io.original_filename.split("/").last.split(".").last
|
||||
original , ending = io.original_filename.split("/").last.split(".")
|
||||
filename = original if( filename.blank? )
|
||||
full_filename = filename + "." + ending
|
||||
File.open(Rails.root.join(Image.root, full_filename), "wb") do |f|
|
||||
f.write( io.read )
|
||||
|
Reference in New Issue
Block a user