Deprecations in Rails 1.2 7

Posted by Bob Silva Thu, 02 Nov 2006 19:40:00 GMT

Here is a quick list of deprecations in Rails 1.2. Update your code now to make upgrading easier later. Some of these have actually been around since before the current release of 1.1.6 but I thought I'd mention them anyways.
Deprecations in Rails 1.2

* Passing method reference symbols to ActionController::Base#url_for. Use named routes instead.
* Calling ActionController::Base#render with string arguments. Ex: render('weblog/show')
* Using model, service, observer, depend_on and dependencies_on in your controller. Rails handles most dependency issues automatically now.
* Calling keep_flash instead of flash.keep
* Pagination will be extracted out into a plugin in Rails 2.0
* Auto complete will be extracted out into a plugin in Rails 2.0
* In place editing will be extracted out into a plugin in Rails 2.0
* start_form_tag and end_form_tag have been deprecated. form_tag still works the same, but there is no wrapper method for the . The preferred method is to use the new block form of form_tag. Ex: form_tag :action => :create do ... end
* The number helper method human_size is deprecated in favor of number_to_human_size
* link_to_image and link_image_to helpers are deprecated in favor of wrapping an image_tag in a link_to. Ex: link_to(image_tag(...), :action => :new)
* Using @cookies, @flash, @headers, @params, @request, @response or @session has been deprecated. Use the method form without the @. Ex: response.content_type
* Calling content_for :layout || :symbol. Use yield || yield :symbol instead
* Calling image_tag without an extension is deprecated. Auto appending .png will be removed. Don't be lazy.
* Passing :post as a link_to modifier to force a POST request via a link tag. Use :method => :post instead.
* push_with_attributes and concat_with_attributes on a HABTM association are deprecated. Use has_many :through with a join model instead.
* find_all and find_first on a has_many association. Use find(:all) and find(:first)
* :dependent => true on a has_many association. Use :dependent => :destroy
* :exclusively_dependent => true on a has_many association. Use :dependent => :delete_all
* When using :class_name on a belongs_to association, the foreign_key name will be inferred from the association rather than the :class_name. Therefor, use :foreign_key if using :class_name and they differ.
* A welcome deprecation, internally, the quote method of ActiveRecord has been renamed. After Rails 2.0 you will be able to use a column named quote again.
* Calling count on a model with string arguments for conditions and joins. Use an options hash instead. Ex: Model.count(:conditions => '...')
* Validations helper method add_on_boundary_breaking in favor of validates_length_of
* Hash extension create_from_xml has been renamed to from_xml
* All the old rake tasks have been moved to namespaced task, old ones are deprected. Ex: rake db:migrate instead of rake migrate
Comments

Leave a response

  1. thread about 9 hours later:
    Enlightening! Thanks for the list!
  2. Jan Wikholm about 19 hours later:
    Thanks for the summary!
  3. jschairb about 20 hours later:
    Quick question that I haven't been able to find out. Do the deprecation warnings show in the logs when you call either the old or the new function? For example, I call flash[:success] a bit in my app and it keeps telling me that the new syntax is the way that I'm using it. I've made sure all the old syntax was out, my only thought is that the deprecation warnings happen on old and new methods.
  4. markmeves 1 day later:
    could you please site a source for this?
  5. Bob Silva 2 days later:
    The source code is the source for this. What does it matter? You should never believe anything you read online anyways.
  6. Lake Denman about 1 month later:
    Thanks very much for this
  7. Joe Ruby 6 months later:
    It's a major pain in the ass trying to read the code in that box with its tiny horizontal scroll bar.
Comments