Send email in rails - R sir - Run ck editor

0. Check the Mail :::::::::::::::::::::::::::::::::::::::::::::::::::::::::

open console -
PostMailer.welcome_email.deliver_now

............................................................


1. /bin.bash--login + rvm use 2.6.5 

2.  rails -v

3.  Web packer error :: 

nvm install v14.10.1

bundle exec rails webpacker:install

4.rails g scaffold Post description:text 

or 

rails g scaffold User name:string  email:string  description:text

5. add ck editor gem - link - https://github.com/tsechingho/ckeditor-rails

6.gem 'ckeditor_rails' + bundle 

7.add js assets - 

//= require jquery_ujs
//= require ckeditor-jquery

8. add js in application.js - same as it is - require.jquery should be at the front 

//= require jquery
 //= require jquery_ujs
 //= require ckeditor-jquery

9. add ckeditor template - application.html.erb
.........................................................................................................................

<!DOCTYPE html>
<html>
  <head>
    <title>Ckeditoremailtemplate</title>
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <%= csrf_meta_tags %>
    <%= csp_meta_tag %>

    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
  </head>

  <body>
    <%= yield %>
  </body>
</html>
..................................................................................................................................
note - change pack with include 

10. socket error will come to remove it 
uncomment the below line in the config/initializers/assets.rb - 
Rails.application.config.assets.precompile += %w( application.js )

11. Add post model - 
rails g scaffold text:text 
(already added this scaffold before in documentation )

12. Add this code in the post model - inside script tag after form end 
in file - app/views/posts/application.html.erb --  

<% end %>

<script type="text/javascript">
  $('.ckeditor').ckeditor({
  // optional config
});
</script>

...................................................................

<script type="text/javascript">
  $('.ckeditor').ckeditor({
  // optional config
});
</script>

...................................................................

13.in posts/show.html - add the html.safe
<p>
  <strong>Text:</strong>
  <%= @post.text.html_safe %>
</p>

14. letter opener -- Add this by link -  https://github.com/ryanb/letter_opener

add this gem and bundle 

gem "letter_opener", group: :development
+ bundle 

15. Then set the delivery method in config/environments/development.rb
config.action_mailer.delivery_method = :letter_opener
config.action_mailer.perform_deliveries = true
16. Add mailer --------
link ::
16.a - rails g mailer Post
16.b - in mailer/post_mailer.rb - 
app/mailers/post_mailer.rb - 
class PostMailer < ApplicationMailer
 def welcome_email
      @url  = 'http://www.gmail.com'
      mail(to: "dwijendra.parashar@yopmail.com", subject: 'Welcome to My Awesome Site')
   end
end

note - this is the hard quoted string in mail static i used
16.c - views/post_mailer/welcome_email.html.erb - add this code with html_safe -
<%= Post.last.text.html_safe %>
16.d -
open console -
PostMailer.welcome_email.deliver_now
17.
gem 'jquery-rails'
yeh gem bhi lagega 


this error is coming in every project of email template with 
ckeditor , open letter 



................................................................

................................................................


.....
email template kaise kam karega 
send_email karna hai rails se usko dekhna hoga
kisi table mein text naam ka column hai usmein hum ck editor laga dete hein , 
render template email mila hi nai r sir ko usmein -- 

...

jo design banaya hai wohi data jayega mail ke through 

ck editor gem lagana padhega ismein mujhe 
table jo banega usmein – text nam ka column rakho bus 

open letter laga lo
ck editor laga lo
open letter mein khol kar dekh lo jo ki ck editor mein lgaya hai 
model mein text likh do 


.................


... Documentation Link ::

https://www.blogger.com/blog/post/edit/4759790771070919523/112344046072181293

Dear Sir ,
Has done application with ckeditor+ mailer+ letter opener – attached screens are there below is the github link
github link - https://github.com/dwijendraparashartech/ckmailertemplate.gitand now work at email_template with the help of chumaroung project and internet
Understanding with the flow of Fee Assignment Module.


Email Template Start ======

.....................................

rails g model InvoiceTemplate template_name:string body:text created_on:datetime  from:string cc:string bcc:string  created_by:string subject:string email_content:string 

rails g model InvoiceEmailContent  invoice_no:string invoice_date:string due_date:string  user_regards:string 

.....................................


rails g scaffold InvoiceTemplate template_name:string body:text created_on:datetime  from:string cc:string bcc:string  created_by:string subject:string email_content:string  invoice_email_content_id:integer  


rails g scaffold InvoiceEmailContent  invoice_no:string invoice_date:string due_date:string  user_regards:string 

..........

rails g model CreateNotificationTemplates body:text path:string locale:string handler:string partial:boolean format:string




Comments

Popular posts from this blog

Rails 7 Features :: Comparison with Rails 6 and Rails 5