A
A
Anton Misyagin2016-05-22 19:53:19
Ruby on Rails
Anton Misyagin, 2016-05-22 19:53:19

Gems devise and backup don't understand Cyrillic?

The problem started after I tied the site address (it is Cyrillic) to my ip. Problems arise when sending mail when performing a backup and when registering a user (well, and other actions in which devise sends a letter). I did not fully understand the nature of the error, but there is a strong suspicion that this is due to my domain name. Other letters which I send from controllers are sent normally. Here's the error I'm getting:

An ActionView::Template::Error occurred in background at 2016-05-22 16:43:50 +0300 :

  incompatible character encodings: UTF-8 and ASCII-8BIT
  /var/www/4e4o/releases/20160522085506/app/views/devise/mailer/confirmation_instructions.html.haml:2:in `_app_views_devise_mailer_confirmation_instructions_html_haml___1275780348649185615_74784040'

  -------------------------------
Backtrace:
-------------------------------

  /var/www/4e4o/releases/20160522085506/app/views/devise/mailer/confirmation_instructions.html.haml:2:in `_app_views_devise_mailer_confirmation_instructions_html_haml___1275780348649185615_74784040'
  /var/www/4e4o/shared/bundle/ruby/2.1.0/gems/actionview-4.2.5/lib/action_view/template.rb:145:in `block in render'
  /var/www/4e4o/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.5/lib/active_support/notifications.rb:166:in `instrument'
  /var/www/4e4o/shared/bundle/ruby/2.1.0/gems/actionview-4.2.5/lib/action_view/template.rb:333:in `instrument'
  /var/www/4e4o/shared/bundle/ruby/2.1.0/gems/actionview-4.2.5/lib/action_view/template.rb:143:in `render'
  /var/www/4e4o/shared/bundle/ruby/2.1.0/gems/actionview-4.2.5/lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
  /var/www/4e4o/shared/bundle/ruby/2.1.0/gems/actionview-4.2.5/lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
  /var/www/4e4o/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.5/lib/active_support/notifications.rb:164:in `block in instrument'
и т.д.

Looked at several threads with the same problem. But what I found does not help me, namely:
/config/application.rb
config.encoding = 'utf-8'
config.action_mailer.default :charset => 'utf-8'

/config/environment.rb
# Load the Rails application.
require File.expand_path('../application', __FILE__)

Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8

# Initialize the Rails application.
Rails.application.initialize!

Now, if I deal with backup separately, then if I specify ip instead of a domain name, then everything is fine, if vice versa, then the same error occurs
notify_by Mail do |mail|
    mail.on_success		= true
    mail.on_failure		= true

    mail.from			= smtp_config['default_mail']
    mail.to				= smtp_config['default_mail']
    mail.address		= smtp_config['smtp_server']
    mail.port			= smtp_config['smtp_port']
    mail.domain			= <b>вот здесь</b>
    mail.user_name		= smtp_config['smtp_user']
    mail.password		= smtp_config['smtp_password']
    mail.authentication	= smtp_config['smtp_authentication']
    mail.encryption		= :starttls
  end

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2016-05-22
@sunnmas

Add to the beginning of the Cyrillic file after the shebang
Or use ascii domain mapping

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question