Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 4943

Show
Ignore:
Timestamp:
09/03/06 22:35:31 (2 years ago)
Author:
david
Message:

More deprecation fun

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/base.rb

    r4860 r4943  
    486486      def url_for(options = {}, *parameters_for_method_reference) #:doc: 
    487487        case options 
    488           when String then options 
    489           when Symbol then send(options, *parameters_for_method_reference) 
    490           when Hash   then @url.rewrite(rewrite_options(options)) 
     488          when String 
     489            options 
     490 
     491          when Symbol 
     492            ActiveSupport::Deprecation.warn( 
     493              "WARNING: You called url_for(:#{options}), which is a deprecated API. Instead you should use the named " + 
     494              "route directly, like #{options}(). Using symbols and parameters with url_for will be removed from Rails 2.0." 
     495            ) 
     496 
     497            send(options, *parameters_for_method_reference) 
     498 
     499          when Hash 
     500            @url.rewrite(rewrite_options(options)) 
    491501        end 
    492502      end 
     
    662672        raise DoubleRenderError, "Can only render or redirect once per action" if performed? 
    663673 
    664         # Backwards compatibility 
    665         unless options.is_a?(Hash) 
    666           if options == :update 
    667             options = {:update => true} 
    668           else 
    669             return render_file(options || default_template_name, deprecated_status, true) 
     674        if options.nil? 
     675          return render_file(default_template_name) 
     676        else 
     677          # Backwards compatibility 
     678          unless options.is_a?(Hash) 
     679            if options == :update 
     680              options = { :update => true } 
     681            else 
     682              ActiveSupport::Deprecation.warn( 
     683                "WARNING: You called render(#{options}), which is a deprecated API. Instead you use " + 
     684                "render :file => #{options}. Calling render with just a string will be removed from Rails 2.0." 
     685              ) 
     686 
     687              return render_file(options || default_template_name, deprecated_status, true) 
     688            end 
    670689          end 
    671690        end 
     
    876895              response.redirected_to = options 
    877896            else 
     897              # TOOD: Deprecate me! 
    878898              redirect_to(url_for(options, *parameters_for_method_reference)) 
    879899              response.redirected_to, response.redirected_to_method_params = options, parameters_for_method_reference 
  • trunk/actionpack/test/controller/url_rewriter_test.rb

    r4814 r4943  
    9191    ActionController::Routing::Routes.load! 
    9292  end 
    93    
    9493end 
  • trunk/activesupport/lib/active_support/deprecation.rb

    r4939 r4943  
    3939        def deprecation_message(callstack, message = nil) 
    4040          file, line, method = extract_callstack(callstack) 
    41           message ||= "WARNING: #{method} is deprecated and will be removed from Rails 2.0. " + 
    42           "See http://www.rubyonrails.org/deprecation for details." 
    43           "#{message} (#{method} at #{file}:#{line})" 
     41          message ||= "WARNING: #{method} is deprecated and will be removed from Rails 2.0." 
     42          "#{message}. See http://www.rubyonrails.org/deprecation for details. (#{method} at #{file}:#{line})" 
    4443        end 
    4544