Posts Tagged: rails 3


17
Jan 11

Rails 3 and the little known :enable_starttls_auto option

I just got the following error from ActionMailer when trying to send to a Gmail address:

OpenSSL::SSL::SSLError (hostname was not match with the server certificate)

After some Googling I found the “enable_starttls_auto” option in ActionMailer, setting this to “false” in the relevant environment file fixed the problem:

  config.action_mailer.smtp_settings = {
    :address => '...',
    :user_name => '...',
    :domain => '...',
    :password => '...',
    :authentication => :login,
    :enable_starttls_auto => false
  }

This option apparently “Enables SMTP/TLS (STARTTLS) for this object if server accepts”. Not being up on my “SMTP/TLS”‘s, I have no idea what this means but it solves the problem.

Hope this saves someone some time.


14
Jan 11

Fixing {{model}} placeholders in Rails 2.3 when Rails 3 is installed

This was causing me all kinds of grief. I am running Rails 2.3 and Rails 3 apps on the same server and on installing Rails 3, the Rails 2.3 apps started displaying {{model}} and similar strings in views.

It turns out that Rails 3 uses i18n version 0.5.0 and with this version as far as I can see, the placeholder text in translations follow the %{text} format instead of the {{text}} format in 0.4.2 which Rails 2.3 was using. The only way I found to fix this was to declare the specific i18n version before the Rails gem gets required in the “load_rails_gem” method of “config/boot.rb” in my Rails 2.3 apps:

def load_rails_gem
  gem 'i18n', '0.4.2' # Add this line
 
  if version...
end

Doing this specifies that we want i18n 0.4.2 exactly, whereas Rails 2.3 specifies version “>= 0.1.3″ which would obviously includes “0.5.0″.

In running Rails 2.3 and Rails 3 apps side by side, I also ran into this problem and overcame it with the fixes by “bct” and “ronin-95281” in the comments… apparently Rails Core won’t fix this.

If anyone else has a cleaner fix for this I would love to hear about it.