Send "carrierwave" gem attachments via email Ruby on Rails -
i using carrierwave gem + mercury editor , want allow users create mail campaigns , send them. works well, have problems inline images.
in image_uploader.rb have
def store_dir "#{uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end
i have newsletters.contents column, , includes preformatted html mercury including images.
so in email .eml file have path <img src="uploads/...">
instead of <img src="http://uploads/...">
if change path #{rails.root}/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}
uploading not working @ all.
is there way fix this?
i solved adding gsub in mercury_update controller action
def mercury_update newsletter = newsletter.find(params[:id]) newsletter.title = params[:content][:newsletter_title][:value] newsletter.content = params[:content][:newsletter_content][:value] newsletter.update_attributes(content: newsletter.content.sub!('<img src="/uploads/', '<img src="http://host.com/uploads/')) newsletter.save! render text: "" end
but feel ugly solution
Comments
Post a Comment