paperclip is dead to me

This commit is contained in:
Yuki 2015-08-26 01:41:30 +05:30
parent ad8506ee5f
commit cd6c746e4d
2 changed files with 19 additions and 9 deletions

View File

@ -1,4 +1,14 @@
module ThemeHelper
class ThemeIO < StringIO
def content_type
'text/css'
end
def original_filename
'theme.css'
end
end
def render_theme_with_context(context = {})
klass = Class.new do
def initialize(hash = {})

View File

@ -16,24 +16,24 @@ class Theme < ActiveRecord::Base
allow_nil: true, only_integer: true
has_attached_file :css, use_timestamp: false, s3_headers: {
'Content-Type' => 'text/css'
'Content-Type' => 'text/css',
'Content-Disposition' => 'attachment; filename=theme.css'
}, fog_file: {
content_type: 'text/css'
content_type: 'text/css',
content_disposition: "attachment; filename=theme.css"
}
validates_attachment_content_type :css, content_type: /^text\//
before_save do
self.css = nil
style = StringIO.new(render_theme_with_context(self))
style = ThemeIO.new(render_theme_with_context(self))
style.class.class_eval {
attr_accessor :original_filename, :content_type
}
style.content_type = 'text/css'
style.original_filename = 'theme.css'
style.instance_variable_set '@content_type', 'text/css'
self.css = style
self.css.instance_write :content_type, 'text/css'
self.css_content_Type = 'text/css'
end
end