lib/jt-rails-toolbox.rb in jt-rails-toolbox-2.4.3 vs lib/jt-rails-toolbox.rb in jt-rails-toolbox-2.5.0

- old
+ new

@@ -5,10 +5,12 @@ require 'validates_phone_format_of' require 'rails_i18n' require 'jt-rails-meta' require 'jt-rails-generator-user' require 'jt-rails-tokenizable' +require 'oj' +require 'oj_mimic_json' require 'yaml' module JTRailsToolbox @@ -142,12 +144,15 @@ Paperclip::Attachment.default_options[:convert_options] = { all: '-strip' } # Params in url are bad for SEO, it's better to use fingerprint for having an unique url Paperclip::Attachment.default_options[:use_timestamp] = false - path = "#{@params['files']['folder']}/:class/:attachment/:id/:style/:fingerprint.:content_type_extension" + path = @params['files']['folder'].to_s + path = "/#{path}" if !path.start_with?('/') + path += '/' if !path.end_with?('/') + path += ":class/:attachment/:id/:style/:fingerprint.:content_type_extension" - Paperclip::Attachment.default_options[:path] = ":rails_root/public/#{path}" + Paperclip::Attachment.default_options[:path] = ":rails_root/public#{path}" Paperclip::Attachment.default_options[:url] = "#{@params['hosts']['cdn_host']}#{path}" ActionController::Base.asset_host = @params['hosts']['asset_host'] app.config.action_controller.asset_host = @params['hosts']['asset_host'] end \ No newline at end of file