Last active
December 24, 2015 23:29
-
-
Save amolpujari/6880037 to your computer and use it in GitHub Desktop.
rails user modifies email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gem 'ckeditor_rails' # from https://github.com/tsechingho/ckeditor-rails | |
# allow modifying existing template | |
<textarea name="modified_email" class="ckeditor"> | |
<%= File.read "#{Rails.root.to_s}/app/views/user_mailer/do_email.html.erb"%> | |
</textarea> | |
<%= javascript_include_tag "ckeditor-jquery" %> | |
<script type="text/javascript"> | |
$('.ckeditor').ckeditor({ | |
height: "800px", | |
allowedContent: true, | |
toolbar: [ | |
{ name: 'document', items : [ 'Source', '-', 'Undo','Redo', '-','SpellChecker'] }, | |
{ name: 'basicstyles', items : [ '-', 'Bold','Italic','Underline'] }, | |
{ name: 'colors', items : [ '-', 'TextColor','BGColor' ] }, | |
{ name: 'styles', items : [ '-', 'Styles','Format','Font','FontSize' ] }, | |
{ name: 'tools', items : [ '-', 'Maximize' ] } | |
] | |
}); | |
setTimeout(function(){ | |
$("a.cke_button").attr("style", "padding:8px;"); | |
$(".cke_chrome").attr("style", "width: 76% !important; overflow: hidden;"); | |
}, 500); | |
</script> | |
# in your mailer | |
def do_email modified_contents | |
body = ActionView::Base.new.render :inline => CGI.unescapeHTML(modified_contents), :locals => { :token => token } | |
# you can have assigns as well | |
mail :to => recipients, | |
:subject => "Do Email", | |
:content_type => "text/html", | |
:body => body | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment