2016-03-30 25 views
1

İçerik oluşturmak ve abonelere postalamak için Creditor, Paperclip ve Mailer (ızgara gönder) kullanıyorum. Sunucuma bir resim yüklüyorum ve web sitesinde :content'da doğru şekilde gösteriliyor, ancak kullanıcılar e-postalarında boş bir görüntü alıyorlar.Resim Rails postasında görünmüyor

<body> 
    <h3>Hi <%= @listener.name %>, </h3> 
    <p><h3>You have received a message from <%= @message.speaker.organization %></p></h3><br/> 
    <!-- <p><%= @message.speaker.fullname %> has sent a message to you.</p><br/> --> 
    <h3 style="color: #000;">Description: <strong style="font-size: 12px; color: #444;"><%= @message.description %></strong></h3><hr/> 
    <p style="font-size: 12px;"><%= raw @message.content %></p><br/> 
</body> 

Ve mailler:

Bu

benim mailler organıdır alacaklı

CKEDITOR.editorConfig = function(config) { 
    //config.language = 'es'; //this could be any language 
    config.width = '650'; 
    config.height = '500'; 
    config.baseHref = 'http://messagefollower.com'; 



    // Filebrowser routes 
    // The location of an external file browser, that should be launched when "Browse Server" button is pressed. 
    config.filebrowserBrowseUrl = "/ckeditor/attachment_files"; 
    // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog. 
    config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files"; 
    // The location of a script that handles file uploads in the Flash dialog. 
    config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files"; 
    // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Link tab of Image dialog. 
    config.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures"; 
    // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Image dialog. 
    config.filebrowserImageBrowseUrl = "/ckeditor/pictures"; 
    // The location of a script that handles file uploads in the Image dialog. 
    config.filebrowserImageUploadUrl = "/ckeditor/pictures"; 
    // The location of a script that handles file uploads. 
    config.filebrowserUploadUrl = "/ckeditor/attachment_files"; 

// You could delete or reorder any of this elements as you wish 
    config.toolbar_Menu = [ 
    { name: 'document', items: ['Source', '-', 'Save'] }, 
    { name: 'clipboard', items: ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'] }, 
    { name: 'editing', items: ['SelectAll', '-', 'SpellChecker', 'Scayt'] }, 
    { name: 'tools', items: ['Maximize', 'ShowBlocks', '-'] }, '/', 
    { name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'] }, 
    { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'] }, 
    { name: 'links', items: ['Link', 'Unlink', 'Anchor'] }, '/', 
    { name: 'styles', items: ['Styles', 'Format', 'Font', 'FontSize'] }, 
    { name: 'colors', items: ['TextColor', 'BGColor'] }, 
    { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak'] } 
    ]; 
    config.toolbar = 'Menu'; 
    return true; 
}; 

benim attachment.rb için

class MessageMailer < ActionMailer::Base 
    default from: "[email protected]" 

    def mail_message_to_listener(message, listener) 
    @message = message 
    @listener = listener 
    if @message.image? 
     message_image_path = @message.get_image_path 
     attachments[@message.image_file_name] = File.read(message_image_path) 
    end 
    mail(to: @listener.email, subject: "#{@message.title}, Part 1") 
    end 

    def mail_message_part_to_listener(messagepart, listener) 
    @messagepart = messagepart 
    @listener = listener 
    message_title = @messagepart.message.title 
    part_number = @messagepart.part_no 
    if @messagepart.image? 
     message_part_image_path = @messagepart.get_image_path 
     attachments[@messagepart.image_file_name] = File.read(message_part_image_path) 
    end 
    mail(to: @listener.email, subject: "#{part_number.ordinalize} part of #{message_title}, Part #{part_number+1}") 
    end 
end 

benim config.js

class Ckeditor::AttachmentFile < Ckeditor::Asset 
    has_attached_file :data, 
        :url => "/ckeditor_assets/attachments/:id/:filename", 
        :path => ":rails_root/public/ckeditor_assets/attachments/:id/:filename" 

    validates_attachment_presence :data 
    validates_attachment_size :data, :less_than => 100.megabytes 
    do_not_validate_attachment_file_type :data 

    def url_thumb 
    @url_thumb ||= Ckeditor::Utils.filethumb(filename) 
    end 
end 
+0

Yani 'message.content' özniteliğinde mi? Göreli bir URL kullanacak. Bunu yapılandırmamalısınız. [Docs] 'dan (http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-baseHref) –

+0

tamamlayabildiğinize benziyor. Tamam, bir – Boris

+0

deneyin config.js dosyasında url config.baseHref = 'messagefollower.com/public/ckeditor_assets/pictures/:id/…; satır, ama bir kaynak olarak ckeditorda gösterir src = "/ ckeditor_assets/pictures/10/content_kolom-300-400x400.jpg" Nerede düzeltirim? – Boris

cevap

0

Muhtemelen, @message.content'unuzdaki URL'lerin mutlak olmaması nedeniyle, ana makine adını içermiyorlar.

CKEditor ürününün config.baseHref adresini site adresinize ayarlayın, varsayılan değer boş.

Diğer yol ise içeriği ön işlemden geçirir ve href="/some/path" değerini href="http://your.address.com/some/path" olarak değiştirir.

+0

bunu bir deneyin – Boris

+0

HI, i config.baseHref = 'http://messagefollower.com' ekledim; ancak yine de resim e-postada görüntülenmedi. Başka önerileriniz var mı? – Boris

+0

@Boris bunu test etmek için e-posta göndermeniz gerekmez - html'de mutlak bağlantılar olmasını istiyorsanız, @ message.content' içindeki 'img' etiketlerine bakın. Eğer ckeditor bu doğru yapmak yapamazsanız, o zaman göndermeden önce değiştirin. – Vasfed