lots of name fixes to get views to work in the app
This commit is contained in:
@ -1,5 +0,0 @@
|
||||
module Merged
|
||||
class ApplicationRecord < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
end
|
||||
end
|
@ -11,7 +11,7 @@ module Merged
|
||||
def initialize(filename)
|
||||
puts "New Image #{filename}"
|
||||
@name , @type = filename.split(".")
|
||||
file = File.new(Rails.root.join(Image.root,filename))
|
||||
file = File.new(Rails.root.join(Image.asset_root,filename))
|
||||
@created_at = file.birthtime
|
||||
@updated_at = file.ctime
|
||||
@size = (file.size/1024).to_i
|
||||
@ -19,7 +19,7 @@ module Merged
|
||||
|
||||
def self.all
|
||||
return @@images unless @@images.empty?
|
||||
Dir[Rails.root.join Image.root + "*.*"].each do |f|
|
||||
Dir[Rails.root.join Image.asset_root + "*.*"].each do |f|
|
||||
file = f.split("/").last
|
||||
self.add( file )
|
||||
end
|
||||
@ -31,14 +31,18 @@ module Merged
|
||||
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|
|
||||
File.open(Rails.root.join(Image.asset_root, full_filename), "wb") do |f|
|
||||
f.write( io.read )
|
||||
end
|
||||
self.add( full_filename )
|
||||
end
|
||||
|
||||
def self.asset_root
|
||||
"app/assets/images/" + root
|
||||
end
|
||||
|
||||
def self.root
|
||||
"app/assets/images/merge/"
|
||||
"cms"
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -4,7 +4,8 @@ module Merged
|
||||
include ActiveModel::Conversion
|
||||
extend ActiveModel::Naming
|
||||
|
||||
@@files = Set.new Dir.new(Rails.root.join("merge")).children
|
||||
@@root
|
||||
@@files = Set.new Dir.new(Rails.root.join(@@root)).children
|
||||
|
||||
attr_reader :name , :content
|
||||
|
||||
@ -16,7 +17,7 @@ module Merged
|
||||
|
||||
def initialize file_name
|
||||
@name = file_name.split(".").first
|
||||
@content = YAML.load_file(Rails.root.join("merge" , file_name))
|
||||
@content = YAML.load_file(Rails.root.join(@@root , file_name))
|
||||
end
|
||||
|
||||
def sections
|
||||
@ -47,7 +48,7 @@ module Merged
|
||||
end
|
||||
|
||||
def save
|
||||
file_name = Rails.root.join("merge" , name + ".yaml")
|
||||
file_name = Rails.root.join(@root , name + ".yaml")
|
||||
File.write( file_name , @content.to_yaml)
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user