Rails 2.0 deprecations

The Rails core team is cleaning up. That’s obviously a good thing, however it does leave us facing a kabillion deprecation warnings when running tests and whatnot.

Unfortunately the official deprecations page appears to have been thrown together quickly after someone noticed that Rails 1.2 had been pushed out without anyone finishing the page that all deprecation warnings were referring to.

So what does a smart Rails developer who wants to be ready for Rails 2.0 when that time comes around do? She reads on…

end_form_tag is deprecated

The old, deprecated way The new, supported way
<%= start_form_tag %>
  ...stuff...
<%= end_form_tag %>
<% form_tag do %>
  ...stuff...
<% end %>
<%= form_remote_tag %>
  ...stuff...
<%= end_form_tag %>
<% form_remote_tag do %>
  ...stuff...
<% end %>

Object transactions are deprecated

The old, deprecated way The new, supported way
Model.transaction(foo) do
  ...stuff...
end
Model.transaction do
  ...stuff...
end

server_settings has been renamed smtp_settings

The old, deprecated way The new, supported way
ActionMailer::Base.server_settings = {
  :address  => 'my.smtp.srv'
}
ActionMailer::Base.smtp_settings = {
  :address  => 'my.smtp.srv'
}

start_form_tag is deprecated

The old, deprecated way The new, supported way
<%= start_form_tag %>
  ...stuff...
<%= end_form_tag %>
<% form_tag do %>
  ...stuff...
<% end %>

You called count([“field = ?”, value], nil)

The old, deprecated way The new, supported way
model_or_association.count(['field = ?', value])
model_or_association.count(:conditions => ['field = ?', value])