From c40b1a4a67ccaa3be31edb13399d93da0c628567 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 7 Aug 2006 12:40:14 +0000 Subject: Deprecate direct usage of @params. Update ActionView::Base for instance var deprecation. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4715 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/base.rb | 20 +++++++++++--------- actionpack/lib/action_controller/pagination.rb | 2 +- actionpack/lib/action_controller/rescue.rb | 4 ++-- .../templates/rescues/_request_and_response.rhtml | 2 +- actionpack/lib/action_controller/verification.rb | 4 ++-- 5 files changed, 17 insertions(+), 15 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 03b89826ce..8823076fcc 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -287,17 +287,17 @@ module ActionController #:nodoc: # Holds the request object that's primarily used to get environment variables through access like # request.env["REQUEST_URI"]. attr_accessor :request - + # Holds a hash of all the GET, POST, and Url parameters passed to the action. Accessed like params["post_id"] # to get the post_id. No type casts are made, so all values are returned as strings. - attr_accessor :params - + attr_internal :params + # Holds the response object that's primarily used to set additional HTTP headers through access like # response.headers["Cache-Control"] = "no-cache". Can also be used to access the final body HTML after a template # has been rendered through response.body -- useful for after_filters that wants to manipulate the output, # such as a OutputCompressionFilter. attr_accessor :response - + # Holds a hash of objects in the session. Accessed like session[:person] to get the object tied to the "person" # key. The session will hold any type of object as values, but the key should be a string or symbol. attr_internal :session @@ -932,7 +932,7 @@ module ActionController #:nodoc: end def assign_shortcuts(request, response) - @request, @params, @cookies = request, request.parameters, request.cookies + @request, @_params, @cookies = request, request.parameters, request.cookies @response = response @response.session = request.session @@ -946,7 +946,7 @@ module ActionController #:nodoc: # TODO: assigns cookies headers params request response template - DEPRECATED_INSTANCE_VARIABLES = %w(flash session) + DEPRECATED_INSTANCE_VARIABLES = %w(flash params session) # Gone after 1.2. def assign_deprecated_shortcuts(request, response) @@ -1019,16 +1019,18 @@ module ActionController #:nodoc: end def add_class_variables_to_assigns - %w( template_root logger template_class ignore_missing_templates ).each do |cvar| + %w(template_root logger template_class ignore_missing_templates).each do |cvar| @assigns[cvar] = self.send(cvar) end end def protected_instance_variables if view_controller_internals - [ "@assigns", "@performed_redirect", "@performed_render" ] + %w(@assigns @performed_redirect @performed_render) else - [ "@assigns", "@performed_redirect", "@performed_render", "@request", "@response", "@session", "@cookies", "@template", "@request_origin", "@parent_controller" ] + %w(@assigns @performed_redirect @performed_render + @request @response @_params @_session @session + @cookies @template @request_origin @parent_controller) end end diff --git a/actionpack/lib/action_controller/pagination.rb b/actionpack/lib/action_controller/pagination.rb index f7cd74120e..54084c0361 100644 --- a/actionpack/lib/action_controller/pagination.rb +++ b/actionpack/lib/action_controller/pagination.rb @@ -191,7 +191,7 @@ module ActionController def paginator_and_collection_for(collection_id, options) #:nodoc: klass = options[:class_name].constantize - page = @params[options[:parameter]] + page = params[options[:parameter]] count = count_collection_for_pagination(klass, options) paginator = Paginator.new(self, count, options[:per_page], page) collection = find_collection_for_pagination(klass, options, paginator) diff --git a/actionpack/lib/action_controller/rescue.rb b/actionpack/lib/action_controller/rescue.rb index 9b57d35587..7cd05eab32 100644 --- a/actionpack/lib/action_controller/rescue.rb +++ b/actionpack/lib/action_controller/rescue.rb @@ -79,7 +79,7 @@ module ActionController #:nodoc: begin perform_action_without_rescue rescue Object => exception - if defined?(Breakpoint) && @params["BP-RETRY"] + if defined?(Breakpoint) && params["BP-RETRY"] msg = exception.backtrace.first if md = /^(.+?):(\d+)(?::in `(.+)')?$/.match(msg) then origin_file, origin_line = md[1], md[2].to_i @@ -87,7 +87,7 @@ module ActionController #:nodoc: set_trace_func(lambda do |type, file, line, method, context, klass| if file == origin_file and line == origin_line then set_trace_func(nil) - @params["BP-RETRY"] = false + params["BP-RETRY"] = false callstack = caller callstack.slice!(0) if callstack.first["rescue.rb"] diff --git a/actionpack/lib/action_controller/templates/rescues/_request_and_response.rhtml b/actionpack/lib/action_controller/templates/rescues/_request_and_response.rhtml index 81995320c2..82007ff5e6 100644 --- a/actionpack/lib/action_controller/templates/rescues/_request_and_response.rhtml +++ b/actionpack/lib/action_controller/templates/rescues/_request_and_response.rhtml @@ -11,7 +11,7 @@ <%= form_tag(@request.request_uri, "method" => @request.method) %> - <% for key, values in @params %> + <% for key, values in params %> <% next if key == "BP-RETRY" %> <% for value in Array(values) %> diff --git a/actionpack/lib/action_controller/verification.rb b/actionpack/lib/action_controller/verification.rb index 8e0b255f26..ebf30becac 100644 --- a/actionpack/lib/action_controller/verification.rb +++ b/actionpack/lib/action_controller/verification.rb @@ -76,8 +76,8 @@ module ActionController #:nodoc: def verify_action(options) #:nodoc: prereqs_invalid = - [*options[:params] ].find { |v| @params[v].nil? } || - [*options[:session]].find { |v| @session[v].nil? } || + [*options[:params] ].find { |v| params[v].nil? } || + [*options[:session]].find { |v| session[v].nil? } || [*options[:flash] ].find { |v| flash[v].nil? } if !prereqs_invalid && options[:method] -- cgit v1.2.3