我正在使用Creditor,Paperclip和Mailer(发送网格)来创建内容并将其邮寄给订阅者。我正在将图片上传到我的服务器,并在:content
网站上正确显示,但用户会在其电子邮件中收到空白图片。
这是我的邮件正文:
<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>
我的邮件:
class MessageMailer < ActionMailer::Base
default from: "meditate@messagefollower.com"
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为债权人
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
答案 0 :(得分:0)
很可能是因为@message.content
中的网址不是绝对的,因此不包含主机名。
将CKEditor的config.baseHref
设置为您的网站地址,默认为空。
其他方法是预处理内容并将href="/some/path"
更改为href="http://your.address.com/some/path"
。