Rails 3 deprecated methods

This is the list of methods that have been deprecated in the Rails 3. The following list has been compiled by Paul Schreiber and has been obtained from one of his answers on Stack Overflow..

I found this extremely useful and this is purely to help others looking for similar information.

Railties now deprecates:

RAILS_ROOT in favor of Rails.root,
RAILS_ENV in favor of Rails.env, and
RAILS_DEFAULT_LOGGER in favor of Rails.logger.

ActionController:

  • The cookie_verifier_secret has been deprecated and now instead it is assigned through Rails.application.config.cookie_secret and moved into its own file: config/initializers/cookie_verification_secret.rb.
  • filter_parameter_logging is deprecated in favor of config.filter_parameters << :password.

ActiveRecord

  • named_scope in an Active Record class is deprecated and has been renamed to just scope.
  • save(false) is deprecated, in favor of save(:validate => false).
  • model.errors.on is deprecated in favor of model.errors[]
  • ActiveRecord::Base.colorize_logging and config.active_record.colorize_logging are deprecated in favor of Rails::LogSubscriber.colorize_logging or config.colorize_logging

ActionMailer

  • :charset, :content_type, :mime_version, :implicit_parts_order are all deprecated in favor of ActionMailer.default :key => value style declarations.
  • Mailer dynamic create_method_name and deliver_method_name are deprecated, just call method_name which now returns a Mail::Message object.
  • ActionMailer.deliver(message) is deprecated, just call message.deliver.
    template_root is deprecated, pass options to a render call inside a proc from the format.mime_type method inside the mail generation block
  • The body method to define instance variables is deprecated (body {:ivar => value}), just declare instance variables in the method directly and they will be available in the view.
  • Mailers being in app/models is deprecated, use app/mailers instead.

Though I haven’t been able find anything about the validate method for the model. I have been facing the following deprecation warning and I am not completely clear if the validate method has been deprecated or if the warning refers to something else

Overwriting validate in your models has been deprecated,
please use Base#validate :method_name instead

Hope this is useful

Advertisements

3 thoughts on “Rails 3 deprecated methods

  1. The bit about Overriding verify means that you don’t monkey patch the validate method, instead you use
    ‘validates :method_name’ and then lower down, ‘def method_name’; that in favor of the Rails 2 idiom,
    ‘def validate’.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s