actionpack 1.13.3 → 1.13.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- data/CHANGELOG +44 -2
- data/Rakefile +1 -1
- data/lib/action_controller/assertions/dom_assertions.rb +2 -2
- data/lib/action_controller/assertions/model_assertions.rb +1 -1
- data/lib/action_controller/assertions/response_assertions.rb +2 -0
- data/lib/action_controller/assertions/routing_assertions.rb +1 -0
- data/lib/action_controller/base.rb +7 -1
- data/lib/action_controller/caching.rb +39 -38
- data/lib/action_controller/cgi_ext/pstore_performance_fix.rb +30 -0
- data/lib/action_controller/cgi_ext/raw_post_data_fix.rb +1 -1
- data/lib/action_controller/cgi_process.rb +13 -4
- data/lib/action_controller/cookies.rb +5 -3
- data/lib/action_controller/filters.rb +176 -77
- data/lib/action_controller/integration.rb +31 -21
- data/lib/action_controller/pagination.rb +7 -1
- data/lib/action_controller/resources.rb +117 -32
- data/lib/action_controller/routing.rb +41 -1
- data/lib/action_controller/test_process.rb +5 -2
- data/lib/action_controller/url_rewriter.rb +4 -1
- data/lib/action_controller/verification.rb +1 -0
- data/lib/action_pack/version.rb +1 -1
- data/lib/action_view/base.rb +25 -19
- data/lib/action_view/compiled_templates.rb +2 -2
- data/lib/action_view/helpers/active_record_helper.rb +18 -18
- data/lib/action_view/helpers/debug_helper.rb +10 -0
- data/lib/action_view/helpers/deprecated_helper.rb +3 -0
- data/lib/action_view/helpers/prototype_helper.rb +33 -17
- data/test/activerecord/pagination_test.rb +9 -0
- data/test/controller/addresses_render_test.rb +4 -1
- data/test/controller/base_test.rb +1 -1
- data/test/controller/caching_test.rb +3 -2
- data/test/controller/cookie_test.rb +11 -0
- data/test/controller/deprecation/deprecated_base_methods_test.rb +18 -0
- data/test/controller/filter_params_test.rb +1 -0
- data/test/controller/filters_test.rb +149 -26
- data/test/controller/integration_test.rb +93 -8
- data/test/controller/resources_test.rb +215 -36
- data/test/controller/routing_test.rb +1 -1
- data/test/controller/test_test.rb +16 -0
- data/test/controller/url_rewriter_test.rb +13 -1
- data/test/controller/verification_test.rb +15 -0
- data/test/fixtures/test/hello_world.rxml +2 -1
- data/test/template/asset_tag_helper_test.rb +5 -0
- data/test/template/compiled_templates_test.rb +29 -17
- data/test/template/number_helper_test.rb +1 -1
- data/test/template/prototype_helper_test.rb +2 -2
- metadata +84 -83
@@ -24,6 +24,7 @@ module ActionController #:nodoc:
|
|
24
24
|
attr_accessor :cookies, :session_options
|
25
25
|
attr_accessor :query_parameters, :request_parameters, :path, :session, :env
|
26
26
|
attr_accessor :host
|
27
|
+
attr_reader :request_uri_overridden
|
27
28
|
|
28
29
|
def initialize(query_parameters = nil, request_parameters = nil, session = nil)
|
29
30
|
@query_parameters = query_parameters || {}
|
@@ -67,12 +68,14 @@ module ActionController #:nodoc:
|
|
67
68
|
# Used to check AbstractRequest's request_uri functionality.
|
68
69
|
# Disables the use of @path and @request_uri so superclass can handle those.
|
69
70
|
def set_REQUEST_URI(value)
|
71
|
+
@request_uri_overridden = true
|
70
72
|
@env["REQUEST_URI"] = value
|
71
73
|
@request_uri = nil
|
72
74
|
@path = nil
|
73
75
|
end
|
74
76
|
|
75
77
|
def request_uri=(uri)
|
78
|
+
@env["REQUEST_URI"] = uri
|
76
79
|
@request_uri = uri
|
77
80
|
@path = uri.split("?").first
|
78
81
|
end
|
@@ -426,12 +429,12 @@ module ActionController #:nodoc:
|
|
426
429
|
end
|
427
430
|
|
428
431
|
def build_request_uri(action, parameters)
|
429
|
-
unless @request.
|
432
|
+
unless @request.request_uri_overridden
|
430
433
|
options = @controller.send(:rewrite_options, parameters)
|
431
434
|
options.update(:only_path => true, :action => action)
|
432
435
|
|
433
436
|
url = ActionController::UrlRewriter.new(@request, parameters)
|
434
|
-
@request.
|
437
|
+
@request.request_uri = url.rewrite(options)
|
435
438
|
end
|
436
439
|
end
|
437
440
|
|
@@ -52,8 +52,9 @@ module ActionController
|
|
52
52
|
# Delete the unused options to prevent their appearance in the query string
|
53
53
|
[:protocol, :host, :port].each { |k| options.delete k }
|
54
54
|
end
|
55
|
+
anchor = "##{options.delete(:anchor)}" if options.key?(:anchor)
|
55
56
|
url << Routing::Routes.generate(options, {})
|
56
|
-
return url
|
57
|
+
return "#{url}#{anchor}"
|
57
58
|
end
|
58
59
|
|
59
60
|
end
|
@@ -76,6 +77,7 @@ module ActionController
|
|
76
77
|
alias_method :to_s, :to_str
|
77
78
|
|
78
79
|
private
|
80
|
+
# Given a path and options, returns a rewritten URL string
|
79
81
|
def rewrite_url(path, options)
|
80
82
|
rewritten_url = ""
|
81
83
|
unless options[:only_path]
|
@@ -91,6 +93,7 @@ module ActionController
|
|
91
93
|
rewritten_url
|
92
94
|
end
|
93
95
|
|
96
|
+
# Given a Hash of options, generates a route
|
94
97
|
def rewrite_path(options)
|
95
98
|
options = options.symbolize_keys
|
96
99
|
options.update(options[:params].symbolize_keys) if options[:params]
|
@@ -95,6 +95,7 @@ module ActionController #:nodoc:
|
|
95
95
|
response.headers.update(options[:add_headers]) if options[:add_headers]
|
96
96
|
unless performed?
|
97
97
|
render(options[:render]) if options[:render]
|
98
|
+
options[:redirect_to] = self.send(options[:redirect_to]) if options[:redirect_to].is_a? Symbol
|
98
99
|
redirect_to(options[:redirect_to]) if options[:redirect_to]
|
99
100
|
end
|
100
101
|
return false
|
data/lib/action_pack/version.rb
CHANGED
data/lib/action_view/base.rb
CHANGED
@@ -148,7 +148,7 @@ module ActionView #:nodoc:
|
|
148
148
|
#
|
149
149
|
# This refreshes the sidebar, removes a person element and highlights the user list.
|
150
150
|
#
|
151
|
-
# See the ActionView::Helpers::PrototypeHelper::
|
151
|
+
# See the ActionView::Helpers::PrototypeHelper::GeneratorMethods documentation for more details.
|
152
152
|
class Base
|
153
153
|
include ERB::Util
|
154
154
|
|
@@ -160,7 +160,7 @@ module ActionView #:nodoc:
|
|
160
160
|
attr_internal *ActionController::Base::DEPRECATED_INSTANCE_VARIABLES
|
161
161
|
|
162
162
|
# Specify trim mode for the ERB compiler. Defaults to '-'.
|
163
|
-
# See
|
163
|
+
# See ERb documentation for suitable values.
|
164
164
|
@@erb_trim_mode = '-'
|
165
165
|
cattr_accessor :erb_trim_mode
|
166
166
|
|
@@ -191,17 +191,17 @@ module ActionView #:nodoc:
|
|
191
191
|
end
|
192
192
|
include CompiledTemplates
|
193
193
|
|
194
|
-
#
|
194
|
+
# Maps inline templates to their method names
|
195
195
|
@@method_names = {}
|
196
|
-
#
|
196
|
+
# Map method names to their compile time
|
197
197
|
@@compile_time = {}
|
198
|
-
#
|
198
|
+
# Map method names to the names passed in local assigns so far
|
199
199
|
@@template_args = {}
|
200
|
-
#
|
200
|
+
# Count the number of inline templates
|
201
201
|
@@inline_template_count = 0
|
202
|
-
#
|
203
|
-
#
|
204
|
-
# used by pick_template_extension determines whether ext1 or ext2 will be stored
|
202
|
+
# Maps template paths without extension to their file extension returned by pick_template_extension.
|
203
|
+
# If for a given path, path.ext1 and path.ext2 exist on the file system, the order of extensions
|
204
|
+
# used by pick_template_extension determines whether ext1 or ext2 will be stored.
|
205
205
|
@@cached_template_extension = {}
|
206
206
|
|
207
207
|
class ObjectWrapper < Struct.new(:value) #:nodoc:
|
@@ -305,7 +305,6 @@ module ActionView #:nodoc:
|
|
305
305
|
# Render the provided template with the given local assigns. If the template has not been rendered with the provided
|
306
306
|
# local assigns yet, or if the template has been updated on disk, then the template will be compiled to a method.
|
307
307
|
#
|
308
|
-
|
309
308
|
# Either, but not both, of template and file_path may be nil. If file_path is given, the template
|
310
309
|
# will only be read if it has to be compiled.
|
311
310
|
#
|
@@ -371,10 +370,12 @@ module ActionView #:nodoc:
|
|
371
370
|
end
|
372
371
|
|
373
372
|
private
|
373
|
+
# Builds a string holding the full path of the template including extension
|
374
374
|
def full_template_path(template_path, extension)
|
375
375
|
"#{@base_path}/#{template_path}.#{extension}"
|
376
376
|
end
|
377
377
|
|
378
|
+
# Asserts the existence of a template.
|
378
379
|
def template_exists?(template_path, extension)
|
379
380
|
file_path = full_template_path(template_path, extension)
|
380
381
|
@@method_names.has_key?(file_path) || FileTest.exists?(file_path)
|
@@ -389,6 +390,7 @@ module ActionView #:nodoc:
|
|
389
390
|
@@cache_template_extensions && @@cached_template_extension[template_path]
|
390
391
|
end
|
391
392
|
|
393
|
+
# Determines the template's file extension, such as rhtml, rxml, or rjs.
|
392
394
|
def find_template_extension_for(template_path)
|
393
395
|
if match = delegate_template_exists?(template_path)
|
394
396
|
match.first.to_sym
|
@@ -405,6 +407,7 @@ module ActionView #:nodoc:
|
|
405
407
|
File.read(template_path)
|
406
408
|
end
|
407
409
|
|
410
|
+
# Evaluate the local assigns and pushes them to the view.
|
408
411
|
def evaluate_assigns
|
409
412
|
unless @assigns_added
|
410
413
|
assign_variables_from_controller
|
@@ -416,6 +419,7 @@ module ActionView #:nodoc:
|
|
416
419
|
handler.new(self).render(template, local_assigns)
|
417
420
|
end
|
418
421
|
|
422
|
+
# Assigns instance variables from the controller to the view.
|
419
423
|
def assign_variables_from_controller
|
420
424
|
@assigns.each { |key, value| instance_variable_set("@#{key}", value) }
|
421
425
|
end
|
@@ -427,10 +431,10 @@ module ActionView #:nodoc:
|
|
427
431
|
((args = @@template_args[render_symbol]) && local_assigns.all? { |k,_| args.has_key?(k) })
|
428
432
|
end
|
429
433
|
|
430
|
-
#
|
431
|
-
#
|
432
|
-
#
|
433
|
-
#
|
434
|
+
# Method to check whether template compilation is necessary.
|
435
|
+
# The template will be compiled if the inline template or file has not been compiled yet,
|
436
|
+
# if local_assigns has a new key, which isn't supported by the compiled code yet,
|
437
|
+
# or if the file has changed on disk and checking file mods hasn't been disabled.
|
434
438
|
def compile_template?(template, file_name, local_assigns)
|
435
439
|
method_key = file_name || template
|
436
440
|
render_symbol = @@method_names[method_key]
|
@@ -445,14 +449,15 @@ module ActionView #:nodoc:
|
|
445
449
|
end
|
446
450
|
end
|
447
451
|
|
448
|
-
#
|
452
|
+
# Method to create the source code for a given template.
|
449
453
|
def create_template_source(extension, template, render_symbol, locals)
|
450
454
|
if template_requires_setup?(extension)
|
451
455
|
body = case extension.to_sym
|
452
456
|
when :rxml
|
453
457
|
"controller.response.content_type ||= 'application/xml'\n" +
|
454
|
-
"xml
|
455
|
-
template
|
458
|
+
"xml ||= Builder::XmlMarkup.new(:indent => 2)\n" +
|
459
|
+
template +
|
460
|
+
"\nxml.target!\n"
|
456
461
|
when :rjs
|
457
462
|
"controller.response.content_type ||= 'text/javascript'\n" +
|
458
463
|
"update_page do |page|\n#{template}\nend"
|
@@ -473,11 +478,11 @@ module ActionView #:nodoc:
|
|
473
478
|
"def #{render_symbol}(local_assigns)\n#{locals_code}#{body}\nend"
|
474
479
|
end
|
475
480
|
|
476
|
-
def template_requires_setup?(extension)
|
481
|
+
def template_requires_setup?(extension) #:nodoc:
|
477
482
|
templates_requiring_setup.include? extension.to_s
|
478
483
|
end
|
479
484
|
|
480
|
-
def templates_requiring_setup
|
485
|
+
def templates_requiring_setup #:nodoc:
|
481
486
|
%w(rxml rjs)
|
482
487
|
end
|
483
488
|
|
@@ -501,6 +506,7 @@ module ActionView #:nodoc:
|
|
501
506
|
end
|
502
507
|
end
|
503
508
|
|
509
|
+
# Compile and evaluate the template's code
|
504
510
|
def compile_template(extension, template, file_name, local_assigns)
|
505
511
|
render_symbol = assign_method_name(extension, template, file_name)
|
506
512
|
render_source = create_template_source(extension, template, render_symbol, local_assigns.keys)
|
@@ -3,14 +3,14 @@ module ActionView
|
|
3
3
|
|
4
4
|
# CompiledTemplates modules hold methods that have been compiled.
|
5
5
|
# Templates are compiled into these methods so that they do not need to be
|
6
|
-
#
|
6
|
+
# read and parsed for each request.
|
7
7
|
#
|
8
8
|
# Each template may be compiled into one or more methods. Each method accepts a given
|
9
9
|
# set of parameters which is used to implement local assigns passing.
|
10
10
|
#
|
11
11
|
# To use a compiled template module, create a new instance and include it into the class
|
12
12
|
# in which you want the template to be rendered.
|
13
|
-
class CompiledTemplates < Module
|
13
|
+
class CompiledTemplates < Module
|
14
14
|
attr_reader :method_names
|
15
15
|
|
16
16
|
def initialize
|
@@ -13,17 +13,18 @@ module ActionView
|
|
13
13
|
# is a great of making the record quickly available for editing, but likely to prove lackluster for a complicated real-world form.
|
14
14
|
# In that case, it's better to use the input method and the specialized form methods in link:classes/ActionView/Helpers/FormHelper.html
|
15
15
|
module ActiveRecordHelper
|
16
|
-
# Returns a default input tag for the type of object returned by the method.
|
17
|
-
#
|
16
|
+
# Returns a default input tag for the type of object returned by the method. For example, let's say you have a model
|
17
|
+
# that has an attribute +title+ of type VARCHAR column, and this instance holds "Hello World":
|
18
18
|
# input("post", "title") =>
|
19
19
|
# <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />
|
20
20
|
def input(record_name, method, options = {})
|
21
21
|
InstanceTag.new(record_name, method, self).to_tag(options)
|
22
22
|
end
|
23
23
|
|
24
|
-
# Returns an entire form with input tags
|
25
|
-
#
|
26
|
-
# form("post")
|
24
|
+
# Returns an entire form with all needed input tags for a specified Active Record object. For example, let's say you
|
25
|
+
# have a table model <tt>Post</tt> with attributes named <tt>title</tt> of type <tt>VARCHAR</tt> and <tt>body</tt> of type <tt>TEXT</tt>:
|
26
|
+
# form("post")
|
27
|
+
# That line would yield a form like the following:
|
27
28
|
# <form action='/post/create' method='post'>
|
28
29
|
# <p>
|
29
30
|
# <label for="post_title">Title</label><br />
|
@@ -32,14 +33,13 @@ module ActionView
|
|
32
33
|
# <p>
|
33
34
|
# <label for="post_body">Body</label><br />
|
34
35
|
# <textarea cols="40" id="post_body" name="post[body]" rows="20">
|
35
|
-
# Back to the hill and over it again!
|
36
36
|
# </textarea>
|
37
37
|
# </p>
|
38
38
|
# <input type='submit' value='Create' />
|
39
39
|
# </form>
|
40
40
|
#
|
41
41
|
# It's possible to specialize the form builder by using a different action name and by supplying another
|
42
|
-
# block renderer.
|
42
|
+
# block renderer. For example, let's say you have a model <tt>Entry</tt> with an attribute <tt>message</tt> of type <tt>VARCHAR</tt>:
|
43
43
|
#
|
44
44
|
# form("entry", :action => "sign", :input_block =>
|
45
45
|
# Proc.new { |record, column| "#{column.human_name}: #{input(record, column.name)}<br />" }) =>
|
@@ -74,16 +74,16 @@ module ActionView
|
|
74
74
|
content_tag('form', contents, :action => action, :method => 'post', :enctype => options[:multipart] ? 'multipart/form-data': nil)
|
75
75
|
end
|
76
76
|
|
77
|
-
# Returns a string containing the error message attached to the +method+ on the +object
|
78
|
-
# This error message is wrapped in a DIV tag, which can be
|
79
|
-
# to properly
|
80
|
-
#
|
77
|
+
# Returns a string containing the error message attached to the +method+ on the +object+ if one exists.
|
78
|
+
# This error message is wrapped in a <tt>DIV</tt> tag, which can be extended to include a +prepend_text+ and/or +append_text+
|
79
|
+
# (to properly explain the error), and a +css_class+ to style it accordingly. As an example, let's say you have a model
|
80
|
+
# +post+ that has an error message on the +title+ attribute:
|
81
81
|
#
|
82
82
|
# <%= error_message_on "post", "title" %> =>
|
83
83
|
# <div class="formError">can't be empty</div>
|
84
84
|
#
|
85
|
-
# <%= error_message_on "post", "title", "Title simply ", " (or it won't work)", "inputError" %> =>
|
86
|
-
# <div class="inputError">Title simply can't be empty (or it won't work)
|
85
|
+
# <%= error_message_on "post", "title", "Title simply ", " (or it won't work).", "inputError" %> =>
|
86
|
+
# <div class="inputError">Title simply can't be empty (or it won't work).</div>
|
87
87
|
def error_message_on(object, method, prepend_text = "", append_text = "", css_class = "formError")
|
88
88
|
if (obj = instance_variable_get("@#{object}")) && (errors = obj.errors.on(method))
|
89
89
|
content_tag("div", "#{prepend_text}#{errors.is_a?(Array) ? errors.first : errors}#{append_text}", :class => css_class)
|
@@ -92,11 +92,11 @@ module ActionView
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
# Returns a string with a
|
95
|
+
# Returns a string with a <tt>DIV</tt> containing all of the error messages for the objects located as instance variables by the names
|
96
96
|
# given. If more than one object is specified, the errors for the objects are displayed in the order that the object names are
|
97
97
|
# provided.
|
98
98
|
#
|
99
|
-
# This
|
99
|
+
# This <tt>DIV</tt> can be tailored by the following options:
|
100
100
|
#
|
101
101
|
# * <tt>header_tag</tt> - Used for the header of the error div (default: h2)
|
102
102
|
# * <tt>id</tt> - The id of the error div (default: errorExplanation)
|
@@ -105,12 +105,12 @@ module ActionView
|
|
105
105
|
# any text that you prefer. If <tt>object_name</tt> is not set, the name of
|
106
106
|
# the first object will be used.
|
107
107
|
#
|
108
|
-
#
|
108
|
+
# To specify the display for one object, you simply provide its name as a parameter. For example, for the +User+ model:
|
109
109
|
#
|
110
110
|
# error_messages_for 'user'
|
111
111
|
#
|
112
|
-
#
|
113
|
-
#
|
112
|
+
# To specify more than one object, you simply list them; optionally, you can add an extra +object_name+ parameter, which
|
113
|
+
# be the name in the header.
|
114
114
|
#
|
115
115
|
# error_messages_for 'user_common', 'user', :object_name => 'user'
|
116
116
|
#
|
@@ -3,6 +3,16 @@ module ActionView
|
|
3
3
|
# Provides a set of methods for making it easier to locate problems.
|
4
4
|
module DebugHelper
|
5
5
|
# Returns a <pre>-tag set with the +object+ dumped by YAML. Very readable way to inspect an object.
|
6
|
+
# my_hash = {'first' => 1, 'second' => 'two', 'third' => [1,2,3]}
|
7
|
+
# debug(my_hash)
|
8
|
+
# => <pre class='debug_dump'>---
|
9
|
+
# first: 1
|
10
|
+
# second: two
|
11
|
+
# third:
|
12
|
+
# - 1
|
13
|
+
# - 2
|
14
|
+
# - 3
|
15
|
+
# </pre>
|
6
16
|
def debug(object)
|
7
17
|
begin
|
8
18
|
Marshal::dump(object)
|
@@ -2,6 +2,9 @@ module ActionView
|
|
2
2
|
module Helpers
|
3
3
|
module PrototypeHelper
|
4
4
|
|
5
|
+
# Method to execute an element update using Prototype.
|
6
|
+
# DEPRECATION WARNING: This helper has been depercated; use RJS instead.
|
7
|
+
# See ActionView::Helpers::PrototypeHelper::JavaScriptGenerator::GeneratorMethods for more information.
|
5
8
|
def update_element_function(element_id, options = {}, &block)
|
6
9
|
content = escape_javascript(options[:content] || '')
|
7
10
|
content = escape_javascript(capture(&block)) if block
|
@@ -250,8 +250,10 @@ module ActionView
|
|
250
250
|
return function
|
251
251
|
end
|
252
252
|
|
253
|
-
# Observes the field with the DOM ID specified by +field_id+ and
|
254
|
-
#
|
253
|
+
# Observes the field with the DOM ID specified by +field_id+ and calls a
|
254
|
+
# callback when its contents have changed. The default callback is an
|
255
|
+
# Ajax call. By default the value of the observed field is sent as a
|
256
|
+
# parameter with the Ajax call.
|
255
257
|
#
|
256
258
|
# Required +options+ are either of:
|
257
259
|
# <tt>:url</tt>:: +url_for+-style options for the action to call
|
@@ -268,14 +270,24 @@ module ActionView
|
|
268
270
|
# <tt>:update</tt>:: Specifies the DOM ID of the element whose
|
269
271
|
# innerHTML should be updated with the
|
270
272
|
# XMLHttpRequest response text.
|
271
|
-
# <tt>:with</tt>:: A JavaScript expression specifying the
|
272
|
-
#
|
273
|
-
#
|
274
|
-
#
|
275
|
-
#
|
276
|
-
#
|
277
|
-
#
|
278
|
-
#
|
273
|
+
# <tt>:with</tt>:: A JavaScript expression specifying the parameters
|
274
|
+
# for the XMLHttpRequest. The default is to send the
|
275
|
+
# key and value of the observed field. Any custom
|
276
|
+
# expressions should return a valid URL query string.
|
277
|
+
# The value of the field is stored in the JavaScript
|
278
|
+
# variable +value+.
|
279
|
+
#
|
280
|
+
# Examples
|
281
|
+
#
|
282
|
+
# :with => "'my_custom_key=' + value"
|
283
|
+
# :with => "'person[name]=' + prompt('New name')"
|
284
|
+
# :with => "Form.Element.serialize('other-field')"
|
285
|
+
#
|
286
|
+
# Finally
|
287
|
+
# :with => 'name'
|
288
|
+
# is shorthand for
|
289
|
+
# :with => "'name=' + value"
|
290
|
+
# This essentially just changes the key of the parameter.
|
279
291
|
# <tt>:on</tt>:: Specifies which event handler to observe. By default,
|
280
292
|
# it's set to "changed" for text fields and areas and
|
281
293
|
# "click" for radio buttons and checkboxes. With this,
|
@@ -291,11 +303,15 @@ module ActionView
|
|
291
303
|
build_observer('Form.Element.EventObserver', field_id, options)
|
292
304
|
end
|
293
305
|
end
|
294
|
-
|
295
|
-
#
|
296
|
-
#
|
297
|
-
#
|
298
|
-
#
|
306
|
+
|
307
|
+
# Observes the form with the DOM ID specified by +form_id+ and calls a
|
308
|
+
# callback when its contents have changed. The default callback is an
|
309
|
+
# Ajax call. By default all fields of the observed field are sent as
|
310
|
+
# parameters with the Ajax call.
|
311
|
+
#
|
312
|
+
# The +options+ for +observe_form+ are the same as the options for
|
313
|
+
# +observe_field+. The JavaScript variable +value+ available to the
|
314
|
+
# <tt>:with</tt> option is set to the serialized form by default.
|
299
315
|
def observe_form(form_id, options = {})
|
300
316
|
if options[:frequency]
|
301
317
|
build_observer('Form.Observer', form_id, options)
|
@@ -660,10 +676,10 @@ module ActionView
|
|
660
676
|
end
|
661
677
|
|
662
678
|
def build_observer(klass, name, options = {})
|
663
|
-
if options[:with] &&
|
679
|
+
if options[:with] && (options[:with] !~ /[=(.]/)
|
664
680
|
options[:with] = "'#{options[:with]}=' + value"
|
665
681
|
else
|
666
|
-
options[:with] ||= 'value'
|
682
|
+
options[:with] ||= 'value' unless options[:function]
|
667
683
|
end
|
668
684
|
|
669
685
|
callback = options[:function] || remote_function(options)
|
@@ -5,6 +5,8 @@ class PaginationTest < ActiveRecordTestCase
|
|
5
5
|
|
6
6
|
class PaginationController < ActionController::Base
|
7
7
|
self.template_root = "#{File.dirname(__FILE__)}/../fixtures/"
|
8
|
+
|
9
|
+
around_filter :silence_deprecation_warnings
|
8
10
|
|
9
11
|
def simple_paginate
|
10
12
|
@topic_pages, @topics = paginate(:topics)
|
@@ -67,6 +69,13 @@ class PaginationTest < ActiveRecordTestCase
|
|
67
69
|
:count => "d.id")
|
68
70
|
render :nothing => true
|
69
71
|
end
|
72
|
+
|
73
|
+
|
74
|
+
def silence_deprecation_warnings
|
75
|
+
ActiveSupport::Deprecation.silence do
|
76
|
+
yield
|
77
|
+
end
|
78
|
+
end
|
70
79
|
|
71
80
|
def rescue_errors(e) raise e end
|
72
81
|
|