Pracując nad mailingiem w pewnej aplikacji napisanej w Padrino natrafiłem na “głupi” błąd:

NoMethodError: undefined method `default_encoding' for Mail::Message:Class

Z takim oto stacktracem:

NoMethodError: undefined method `default_encoding' for Mail::Message:Class
	/gems/sinatra-1.1.3/lib/sinatra/base.rb:466:in `render'
	/gems/padrino-core-0.9.19/lib/padrino-core/application/rendering.rb:123:in `render'
	/gems/padrino-mailer-0.9.19/lib/padrino-mailer/ext.rb:228:in `render'
	/home/mencio/app/mailers/signup_mailer.rb:9
	/gems/padrino-mailer-0.9.19/lib/padrino-mailer/base.rb:57:in `instance_exec'
	/gems/padrino-mailer-0.9.19/lib/padrino-mailer/base.rb:57:in `email'
	/gems/padrino-mailer-0.9.19/lib/padrino-mailer/helpers.rb:82:in `call'
	/gems/padrino-mailer-0.9.19/lib/padrino-mailer/helpers.rb:82:in `deliver'
	/gems/padrino-mailer-0.9.19/lib/padrino-mailer/helpers.rb:34:in `deliver'
	/home/mencio/app/controllers/signups.rb:9:in `POST /signup'
	/gems/padrino-core-0.9.19/lib/padrino-core/application/routing.rb:340:in `call'
	/gems/padrino-core-0.9.19/lib/padrino-core/application/routing.rb:340:in `route'
	/gems/sinatra-1.1.3/lib/sinatra/base.rb:649:in `instance_eval'
	/gems/sinatra-1.1.3/lib/sinatra/base.rb:649:in `route_eval'
	/gems/padrino-core-0.9.19/lib/padrino-core/application/routing.rb:605:in `route!'
	/gems/padrino-core-0.9.19/lib/padrino-core/application/routing.rb:605:in `catch'
	/gems/padrino-core-0.9.19/lib/padrino-core/application/routing.rb:605:in `route!'
	/gems/padrino-core-0.9.19/lib/padrino-core/application/routing.rb:596:in `catch'
	/gems/padrino-core-0.9.19/lib/padrino-core/application/routing.rb:596:in `route!'
	/gems/sinatra-1.1.3/lib/sinatra/base.rb:766:in `dispatch!'
	/gems/sinatra-1.1.3/lib/sinatra/base.rb:559:in `call!'
	/gems/sinatra-1.1.3/lib/sinatra/base.rb:731:in `instance_eval'
	/gems/sinatra-1.1.3/lib/sinatra/base.rb:731:in `invoke'
	/gems/sinatra-1.1.3/lib/sinatra/base.rb:731:in `catch'
	/gems/sinatra-1.1.3/lib/sinatra/base.rb:731:in `invoke'
	/gems/sinatra-1.1.3/lib/sinatra/base.rb:559:in `call!'
	/gems/sinatra-1.1.3/lib/sinatra/base.rb:544:in `call'
	/gems/rack-flash-0.1.1/lib/rack/flash.rb:148:in `call'
	/gems/padrino-core-0.9.19/lib/padrino-core/reloader.rb:31:in `call'
	/gems/padrino-core-0.9.19/lib/padrino-core/logger.rb:282:in `call'
	/gems/warden-1.0.3/lib/warden/manager.rb:35:in `call'
	/gems/warden-1.0.3/lib/warden/manager.rb:34:in `catch'
	/gems/warden-1.0.3/lib/warden/manager.rb:34:in `call'
	/gems/rack-less-1.5.0/lib/rack/less/base.rb:40:in `call!'
	/gems/rack-less-1.5.0/lib/rack/less/base.rb:24:in `call'
	/gems/rack-1.2.1/lib/rack/showexceptions.rb:24:in `call'
	/gems/rack-1.2.1/lib/rack/methodoverride.rb:24:in `call'
	/gems/rack-1.2.1/lib/rack/session/cookie.rb:37:in `call'
	/gems/sinatra-1.1.3/lib/sinatra/base.rb:1173:in `call'
	/gems/sinatra-1.1.3/lib/sinatra/base.rb:1199:in `synchronize'
	/gems/sinatra-1.1.3/lib/sinatra/base.rb:1173:in `call'
	/gems/padrino-core-0.9.19/lib/padrino-core/router.rb:71:in `call'
	/gems/padrino-core-0.9.19/lib/padrino-core/router.rb:64:in `each'
	/gems/padrino-core-0.9.19/lib/padrino-core/router.rb:64:in `call'
	/gems/rack-1.2.1/lib/rack/content_length.rb:13:in `call'
	/gems/rack-1.2.1/lib/rack/chunked.rb:15:in `call'
	/gems/thin-1.2.8/lib/thin/connection.rb:84:in `pre_process'
	/gems/thin-1.2.8/lib/thin/connection.rb:82:in `catch'
	/gems/thin-1.2.8/lib/thin/connection.rb:82:in `pre_process'
	/gems/thin-1.2.8/lib/thin/connection.rb:57:in `process'
	/gems/thin-1.2.8/lib/thin/connection.rb:42:in `receive_data'
	/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
	/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
	/gems/thin-1.2.8/lib/thin/backends/base.rb:61:in `start'
	/gems/thin-1.2.8/lib/thin/server.rb:159:in `start'
	/gems/rack-1.2.1/lib/rack/handler/thin.rb:14:in `run'
	/gems/padrino-core-0.9.19/lib/padrino-core/server.rb:43:in `build'
	/gems/padrino-core-0.9.19/lib/padrino-core/server.rb:14:in `run!'
	/gems/padrino-core-0.9.19/lib/padrino-core/cli/adapter.rb:29:in `start'
	/gems/padrino-core-0.9.19/lib/padrino-core/cli/base.rb:23:in `start'
	/gems/thor-0.14.6/lib/thor/task.rb:22:in `send'
	/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
	/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
	/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
	/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
	/gems/padrino-core-0.9.19/bin/padrino:8
	/gems/bin/padrino:19:in `load'
	/gems/bin/padrino:19

Niestety nie znalazłem żadnej wartościowej informacji na temat tego jak to naprawić, tak więc napisałem (brzydki ;) ) workaround który dopisujemy w app/app.rb:

module Mail
  class Message
    def self.default_encoding
    end
  end
end

Przynajmniej na “teraz” rozwiązanie to wydaje się działać.