2016-03-30 23 views
1

私は、Creditor、Paperclip、Mailer(送信グリッド)を使用してコンテンツを作成し、それを購読者にメールしています。サーバーに画像をアップロードしていて、ウェブサイトに正しく:contentに表示されますが、ユーザーはメールで空白の画像を受信します。画像がRailsメールに表示されない

これは私のメーラー体である:

<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> 

そして、私のメーラー:債権者

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; 
}; 

私attachment.rb

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 
ため

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 

私config.jsの

+0

それは 'message.content'属性にありますか?相対URLを使用します。それをしないように設定する必要があります。あなたは[docs](http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-baseHref) –

+0

からそれを設定することができるように見える私はそれを試してみる – Boris

+0

私が参照してください、私は絶対指定私のconfig.jsのURLをconfig.baseHref = 'messagefollower.com/public/ckeditor_assets/pictures/:id/...;; ckeditorのソースとしてはsrc = "/ ckeditor_assets/pictures/10/content_kolom-300-400x400.jpg"と表示されます。 – Boris

答えて

0

ほとんどの場合、あなたの@message.contentのURLは絶対ではないため、ホスト名は含まれていません。

サイトアドレスにCKEditorのconfig.baseHrefを設定すると、デフォルトでは空になります。

他の方法は、コンテンツを事前処理してhref="/some/path"href="http://your.address.com/some/path"に変更することです。

+0

私は試してみます – Boris

+0

HI、config.baseHref = 'http://messagefollower.com'を追加しました。まだ画像は電子メールに表示されませんでした。その他の提案はありますか? – Boris

+0

@Borisそれをテストするには電子メールを送る必要はありません.HTMLで絶対的なリンクが必要なので、 '@ message.content'の中の' img'タグを見てください。 ckeditorがこれらの権利を行使することができない場合は、送信前に変更してください – Vasfed

関連する問題