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

Changeset 4715

Show
Ignore:
Timestamp:
08/07/06 12:40:14 (2 years ago)
Author:
bitsweat
Message:

Deprecate direct usage of @params. Update ActionView::Base for instance var deprecation.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r4713 r4715  
    33* Add support for the param_name parameter to the auto_complete_field helper. #5026 [david.a.williams@gmail.com] 
    44 
    5 * Deprecation! @session and @flash will be removed after 1.2. Use the session and flash methods instead. You'll get printed warnings during tests and logged warnings in dev mode when you access either instance variable directly. [Jeremy Kemper] 
     5* Deprecation! @params, @session, @flash will be removed after 1.2. Use the corresponding instance methods instead. You'll get printed warnings during tests and logged warnings in dev mode when you access either instance variable directly. [Jeremy Kemper] 
    66 
    77* Make Routing noisy when an anchor regexp is assigned to a segment. #5674 [francois.beausoleil@gmail.com] 
  • trunk/actionpack/examples/address_book_controller.rb

    r4 r4715  
    2929   
    3030  def person 
    31     @person = @address_book.find_person(@params["id"]) 
     31    @person = @address_book.find_person(params[:id]) 
    3232  end 
    3333   
    3434  def create_person 
    35     @address_book.create_person(@params["person"]) 
     35    @address_book.create_person(params[:person]) 
    3636    redirect_to :action => "index" 
    3737  end 
  • trunk/actionpack/examples/blog_controller.cgi

    r4699 r4715  
    3333   
    3434  def create 
    35     @session["posts"].unshift(Post.new(@params["post"]["title"], @params["post"]["body"])) 
     35    @session["posts"].unshift(Post.new(params[:post][:title], params[:post][:body])) 
    3636    flash["alert"] = "New post added!" 
    3737    redirect_to :action => "index" 
  • trunk/actionpack/examples/debate_controller.cgi

    r4 r4715  
    2626   
    2727  def topic 
    28     @topic = @debate.find_topic(@params["id"]) 
     28    @topic = @debate.find_topic(params[:id]) 
    2929  end 
    3030   
     
    3232 
    3333  def create_topic 
    34     @debate.create_topic(@params["topic"]) 
     34    @debate.create_topic(params[:topic]) 
    3535    redirect_to :action => "index" 
    3636  end 
    3737 
    3838  def create_reply 
    39     @debate.create_reply(@params["reply"]) 
    40     redirect_to :action => "topic", :path_params => { "id" => @params["reply"]["topic_id"] } 
     39    @debate.create_reply(params[:reply]) 
     40    redirect_to :action => "topic", :path_params => { "id" => params[:reply][:topic_id] } 
    4141  end 
    4242     
  • trunk/actionpack/lib/action_controller/base.rb

    r4699 r4715  
    288288    # <tt>request.env["REQUEST_URI"]</tt>. 
    289289    attr_accessor :request 
    290      
     290 
    291291    # Holds a hash of all the GET, POST, and Url parameters passed to the action. Accessed like <tt>params["post_id"]</tt> 
    292292    # to get the post_id. No type casts are made, so all values are returned as strings. 
    293     attr_accessor :params 
    294      
     293    attr_internal :params 
     294 
    295295    # Holds the response object that's primarily used to set additional HTTP headers through access like  
    296296    # <tt>response.headers["Cache-Control"] = "no-cache"</tt>. Can also be used to access the final body HTML after a template 
     
    298298    # such as a OutputCompressionFilter. 
    299299    attr_accessor :response 
    300      
     300 
    301301    # Holds a hash of objects in the session. Accessed like <tt>session[:person]</tt> to get the object tied to the "person" 
    302302    # key. The session will hold any type of object as values, but the key should be a string or symbol. 
     
    933933 
    934934      def assign_shortcuts(request, response) 
    935         @request, @params, @cookies = request, request.parameters, request.cookies 
     935        @request, @_params, @cookies = request, request.parameters, request.cookies 
    936936 
    937937        @response         = response 
     
    947947 
    948948      # TODO: assigns cookies headers params request response template 
    949       DEPRECATED_INSTANCE_VARIABLES = %w(flash session) 
     949      DEPRECATED_INSTANCE_VARIABLES = %w(flash params session) 
    950950 
    951951      # Gone after 1.2. 
     
    10201020 
    10211021      def add_class_variables_to_assigns 
    1022         %w( template_root logger template_class ignore_missing_templates ).each do |cvar| 
     1022        %w(template_root logger template_class ignore_missing_templates).each do |cvar| 
    10231023          @assigns[cvar] = self.send(cvar) 
    10241024        end 
     
    10271027      def protected_instance_variables 
    10281028        if view_controller_internals 
    1029           [ "@assigns", "@performed_redirect", "@performed_render" ] 
     1029          %w(@assigns @performed_redirect @performed_render) 
    10301030        else 
    1031           [ "@assigns", "@performed_redirect", "@performed_render", "@request", "@response", "@session", "@cookies", "@template", "@request_origin", "@parent_controller" ] 
     1031          %w(@assigns @performed_redirect @performed_render 
     1032             @request @response @_params @_session @session 
     1033             @cookies @template @request_origin @parent_controller) 
    10321034        end 
    10331035      end 
  • trunk/actionpack/lib/action_controller/pagination.rb

    r4476 r4715  
    192192    def paginator_and_collection_for(collection_id, options) #:nodoc: 
    193193      klass = options[:class_name].constantize 
    194       page  = @params[options[:parameter]] 
     194      page  = params[options[:parameter]] 
    195195      count = count_collection_for_pagination(klass, options) 
    196196      paginator = Paginator.new(self, count, options[:per_page], page) 
  • trunk/actionpack/lib/action_controller/rescue.rb

    r4312 r4715  
    8080          perform_action_without_rescue 
    8181        rescue Object => exception 
    82           if defined?(Breakpoint) && @params["BP-RETRY"] 
     82          if defined?(Breakpoint) && params["BP-RETRY"] 
    8383            msg = exception.backtrace.first 
    8484            if md = /^(.+?):(\d+)(?::in `(.+)')?$/.match(msg) then 
     
    8888                if file == origin_file and line == origin_line then 
    8989                  set_trace_func(nil) 
    90                   @params["BP-RETRY"] = false 
     90                  params["BP-RETRY"] = false 
    9191 
    9292                  callstack = caller 
  • trunk/actionpack/lib/action_controller/templates/rescues/_request_and_response.rhtml

    r3060 r4715  
    1212      <input type="hidden" name="BP-RETRY" value="1" /> 
    1313   
    14       <% for key, values in @params %> 
     14      <% for key, values in params %> 
    1515        <% next if key == "BP-RETRY" %> 
    1616        <% for value in Array(values) %> 
  • trunk/actionpack/lib/action_controller/verification.rb

    r4479 r4715  
    7777    def verify_action(options) #:nodoc: 
    7878      prereqs_invalid = 
    79         [*options[:params] ].find { |v| @params[v].nil?  } || 
    80         [*options[:session]].find { |v| @session[v].nil? } || 
     79        [*options[:params] ].find { |v| params[v].nil?  } || 
     80        [*options[:session]].find { |v| session[v].nil? } || 
    8181        [*options[:flash]  ].find { |v| flash[v].nil?    } 
    8282       
  • trunk/actionpack/lib/action_view/base.rb

    r4598 r4715  
    149149    attr_accessor :controller 
    150150 
    151     attr_reader :logger, :params, :request, :response, :session, :headers, :flash 
     151    attr_reader :logger, :request, :response, :headers 
     152    attr_internal :flash, :params, :session 
    152153 
    153154    # Specify trim mode for the ERB compiler. Defaults to '-'. 
  • trunk/actionpack/test/controller/action_pack_assertions_test.rb

    r4404 r4715  
    5555 
    5656  def render_based_on_parameters 
    57     render_text "Mr. #{@params["name"]}" 
     57    render_text "Mr. #{params[:name]}" 
    5858  end 
    5959 
  • trunk/actionpack/test/controller/components_test.rb

    r4474 r4715  
    4747class CalleeController < ActionController::Base 
    4848  def being_called 
    49     render_text "#{@params["name"] || "Lady"} of the House, speaking" 
     49    render_text "#{params[:name] || "Lady"} of the House, speaking" 
    5050  end 
    5151   
  • trunk/actionpack/test/controller/verification_test.rb

    r4201 r4715  
    3535 
    3636    def guarded_one 
    37       render :text => "#{@params["one"]}" 
     37      render :text => "#{params[:one]}" 
    3838    end 
    3939 
    4040    def guarded_with_flash 
    41       render :text => "#{@params["one"]}" 
     41      render :text => "#{params[:one]}" 
    4242    end 
    4343 
    4444    def guarded_two 
    45       render :text => "#{@params["one"]}:#{@params["two"]}" 
     45      render :text => "#{params[:one]}:#{params[:two]}" 
    4646    end 
    4747 
     
    7171 
    7272    def unguarded 
    73       render :text => "#{@params["one"]}" 
     73      render :text => "#{params[:one]}" 
    7474    end 
    7575