I want to email preview for devise confirmation mail etc through rails email preview gem and it integrate with comfortable mexican sofa cms. I need edit mail content through that cms. Rails Email Preview not integrated with comfortable mexican sofa cms for me and I will try my level but not work for me.how do it work i'm not clear about it.Somebody help me
Here My Gemfile
gem 'rails_email_preview', '~> 0.2.28'
gem 'comfortable_mexican_sofa', '~> 1.12.0'
Here My config/initializers/rails_email_preview.rb file
require 'rails_email_preview'
#= REP hooks and config
# RailsEmailPreview.setup do |config|
# # hook before rendering preview:
# config.before_render do |message, preview_class_name, mailer_action|
# # apply premailer-rails:
# Premailer::Rails::Hook.delivering_email(message)
# # or actionmailer-inline-css:
# ActionMailer::InlineCssHook.delivering_email(message)
# end
#
# # do not show Send Email button
# config.enable_send_email = false
#
# # You can specify a controller for RailsEmailPreview::ApplicationController to inherit from:
# config.parent_controller = 'Admin::ApplicationController' # default: '::ApplicationController'
#end
#= REP + Comfortable Mexican Sofa integration
#
# # enable comfortable_mexican_sofa integration:
require 'rails_email_preview/integrations/comfortable_mexica_sofa'
Rails.application.config.to_prepare do
# Render REP inside a custom layout (set to 'application' to use app layout, default is REP's own layout)
# This will also make application routes accessible from within REP:
# RailsEmailPreview.layout = 'admin'
# Set UI locale to something other than :en
# RailsEmailPreview.locale = :de
# Auto-load preview classes from:
RailsEmailPreview.preview_classes = Dir[Rails.root.join 'app/mailer_previews/*_preview.rb'].map { |p|
File.basename(p, '.rb').camelize
}
end
Here My app/mailer_previews/devise_mailer_preview.rb file
class DeviseMailerPreview < ActionMailer::Preview
def confirmation_instructions
user = User.first
DeviseMailer.confirmation_instructions(user)
end
end
Here My app/mailers/devise_mailer.rb file
class DeviseMailer < Devise::Mailer
default from: "from@example.com"
def confirmation_instructions(user)
@user = user
mail to: user.email
end
end
Here My app/views/devise/confirmations/confirmation_instructions.html.erb
<%= @user.name %>,
<p>You can confirm your account email through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @token) %></p>
Here My devise.rb
config.mailer = "DeviseMailer"
Here my routes file
mount RailsEmailPreview::Engine, at: '/emails'
comfy_route :cms_admin, :path => '/admin'
Thanks Your Help!
It's a Rails bug. Fixed in Rails master. For now you just need to redefine mailer preview routes inside your app. See this for more details:
https://github.com/comfy/comfortable-mexican-sofa/issues/553
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.