actionpack 0.9.5 → 1.0.0
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 +177 -0
- data/README +0 -1
- data/install.rb +1 -0
- data/lib/action_controller.rb +6 -1
- data/lib/action_controller/assertions/active_record_assertions.rb +2 -2
- data/lib/action_controller/base.rb +53 -41
- data/lib/action_controller/benchmarking.rb +1 -1
- data/lib/action_controller/cgi_ext/cgi_methods.rb +14 -16
- data/lib/action_controller/cgi_process.rb +16 -6
- data/lib/action_controller/cookies.rb +70 -0
- data/lib/action_controller/dependencies.rb +106 -0
- data/lib/action_controller/helpers.rb +14 -3
- data/lib/action_controller/layout.rb +16 -2
- data/lib/action_controller/request.rb +17 -7
- data/lib/action_controller/rescue.rb +33 -3
- data/lib/action_controller/support/class_inheritable_attributes.rb +4 -0
- data/lib/action_controller/support/inflector.rb +14 -12
- data/lib/action_controller/support/misc.rb +6 -0
- data/lib/action_controller/templates/rescues/_request_and_response.rhtml +2 -2
- data/lib/action_controller/templates/rescues/diagnostics.rhtml +4 -6
- data/lib/action_controller/templates/rescues/template_error.rhtml +1 -9
- data/lib/action_controller/templates/scaffolds/edit.rhtml +2 -1
- data/lib/action_controller/templates/scaffolds/layout.rhtml +36 -0
- data/lib/action_controller/templates/scaffolds/new.rhtml +1 -0
- data/lib/action_controller/test_process.rb +27 -8
- data/lib/action_controller/url_rewriter.rb +15 -4
- data/lib/action_view/base.rb +4 -3
- data/lib/action_view/helpers/active_record_helper.rb +29 -15
- data/lib/action_view/helpers/date_helper.rb +6 -5
- data/lib/action_view/helpers/form_helper.rb +31 -4
- data/lib/action_view/helpers/form_options_helper.rb +13 -3
- data/lib/action_view/helpers/tag_helper.rb +14 -16
- data/lib/action_view/helpers/url_helper.rb +46 -1
- data/lib/action_view/partials.rb +8 -1
- data/lib/action_view/template_error.rb +10 -3
- data/lib/action_view/vendor/builder/blankslate.rb +33 -1
- data/lib/action_view/vendor/builder/xmlevents.rb +1 -1
- data/lib/action_view/vendor/builder/xmlmarkup.rb +1 -1
- data/rakefile +4 -13
- data/test/controller/action_pack_assertions_test.rb +39 -1
- data/test/controller/active_record_assertions_test.rb +6 -5
- data/test/controller/cgi_test.rb +33 -3
- data/test/controller/cookie_test.rb +43 -2
- data/test/controller/helper_test.rb +1 -1
- data/test/controller/render_test.rb +9 -0
- data/test/controller/url_test.rb +16 -0
- data/test/fixtures/scope/test/modgreet.rhtml +1 -0
- data/test/template/active_record_helper_test.rb +34 -8
- data/test/template/date_helper_test.rb +164 -20
- data/test/template/form_helper_test.rb +12 -0
- data/test/template/form_options_helper_test.rb +7 -16
- data/test/template/url_helper_test.rb +12 -0
- metadata +8 -2
data/CHANGELOG
CHANGED
@@ -1,3 +1,180 @@
|
|
1
|
+
*1.0*
|
2
|
+
|
3
|
+
* Added that controllers will now attempt to require a model dependency with their name and in a singular attempt for their name.
|
4
|
+
So both PostController and PostsController will automatically have the post.rb model required. If no model is found, no error is raised,
|
5
|
+
as it is then expected that no match is available and the programmer will have included his own models.
|
6
|
+
|
7
|
+
* Fixed DateHelper#date_select so that you can pass include_blank as an option even if you don't use start_year and end_year #59 [what-a-day]
|
8
|
+
|
9
|
+
* Added that controllers will now search for a layout in $template_root/layouts/$controller_name.r(html|xml), so PostsController will look
|
10
|
+
for layouts/posts.rhtml or layouts/posts.rxml and automatically configure this layout if found #307 [Marcel]
|
11
|
+
|
12
|
+
* Added FormHelper#radio_button to work with radio buttons like its already possible with check boxes [Michael Koziarski]
|
13
|
+
|
14
|
+
* Added TemplateError#backtrace that makes it much easier to debug template errors from unit and functional tests
|
15
|
+
|
16
|
+
* Added display of error messages with scaffolded form pages
|
17
|
+
|
18
|
+
* Added option to ERB templates to swallow newlines by using <% if something -%> instead of just <% if something %>. Example:
|
19
|
+
|
20
|
+
class SomeController < ApplicationController
|
21
|
+
<% if options[:scaffold] %>
|
22
|
+
scaffold :<%= singular_name %>
|
23
|
+
<% end %>
|
24
|
+
helper :post
|
25
|
+
|
26
|
+
...produces this on post as singular_name:
|
27
|
+
|
28
|
+
class SomeController < ApplicationController
|
29
|
+
|
30
|
+
scaffold :post
|
31
|
+
|
32
|
+
helper :post
|
33
|
+
|
34
|
+
...where as:
|
35
|
+
|
36
|
+
class SomeController < ApplicationController
|
37
|
+
<% if options[:scaffold] -%>
|
38
|
+
scaffold :<%= singular_name %>
|
39
|
+
<% end -%>
|
40
|
+
helper :post
|
41
|
+
|
42
|
+
...produces:
|
43
|
+
|
44
|
+
class SomeController < ApplicationController
|
45
|
+
scaffold :post
|
46
|
+
helper :post
|
47
|
+
|
48
|
+
[This undocumented gem for ERb was uncovered by bitsweat]
|
49
|
+
|
50
|
+
* Fixed CgiRequest so that it'll now accept session options with Symbols as keys (as the documentation points out) [Suggested by Andreas]
|
51
|
+
|
52
|
+
* Added that render_partial will always by default include a counter with value 1 unless there is a counter passed in via the
|
53
|
+
local_assigns hash that overrides it. As a result, render_collection_of_partials can still be written in terms of render_partial
|
54
|
+
and partials that make use of a counter can be called without problems from both render_collection_of_partials as well as
|
55
|
+
render_partial #295 [marcel]
|
56
|
+
|
57
|
+
* Fixed CgiRequest#out to fall back to #write if $stdout doesn't have #syswrite [bitsweat]
|
58
|
+
|
59
|
+
* Fixed all helpers so that they use XHTML compliant double quotes for values instead of single quotes [htonl/bitsweat]
|
60
|
+
|
61
|
+
* Added link_to_image(src, options = {}, html_options = {}, *parameters_for_method_reference). Documentation:
|
62
|
+
|
63
|
+
Creates a link tag to the image residing at the +src+ using an URL created by the set of +options+. See the valid options in
|
64
|
+
link:classes/ActionController/Base.html#M000021. It's also possible to pass a string instead of an options hash to
|
65
|
+
get a link tag that just points without consideration. The <tt>html_options</tt> works jointly for the image and ahref tag by
|
66
|
+
letting the following special values enter the options on the image and the rest goes to the ahref:
|
67
|
+
|
68
|
+
::alt: If no alt text is given, the file name part of the +src+ is used (capitalized and without the extension)
|
69
|
+
::size: Supplied as "XxY", so "30x45" becomes width="30" and height="45"
|
70
|
+
::align: Sets the alignment, no special features
|
71
|
+
|
72
|
+
The +src+ can be supplied as a...
|
73
|
+
* full path, like "/my_images/image.gif"
|
74
|
+
* file name, like "rss.gif", that gets expanded to "/images/rss.gif"
|
75
|
+
* file name without extension, like "logo", that gets expanded to "/images/logo.png"
|
76
|
+
|
77
|
+
* Fixed to_input_field_tag so it no longer explicitly uses InstanceTag.value if value was specified in the options hash [evl]
|
78
|
+
|
79
|
+
* Added the possibility of having validate be protected for assert_(in)valid_column #263 [Tobias Luetke]
|
80
|
+
|
81
|
+
* Added that ActiveRecordHelper#form now calls url_for on the :action option.
|
82
|
+
|
83
|
+
* Added all the HTTP methods as alternatives to the generic "process" for functional testing #276 [Tobias Luetke]. Examples:
|
84
|
+
|
85
|
+
# Calls Controller#miletone with a GET request
|
86
|
+
process :milestone
|
87
|
+
|
88
|
+
# Calls Controller#miletone with a POST request that has parameters
|
89
|
+
post :milestone, { "name" => "David" }
|
90
|
+
|
91
|
+
# Calls Controller#milestone with a HEAD request that has both parameters and session data
|
92
|
+
head :milestone, { "id" => 1 }, { "user_id" => 23 }
|
93
|
+
|
94
|
+
This is especially useful for testing idiomatic REST web services.
|
95
|
+
|
96
|
+
* Added proper handling of HEAD requests, so that content isn't returned (Request#head? added as well) #277 [Eric Hodel]
|
97
|
+
|
98
|
+
* Added indifference to whether @headers["Content-Type"], @headers["Content-type"], or @headers["content-type"] is used.
|
99
|
+
|
100
|
+
* Added TestSession#session_id that returns an empty string to make it easier to functional test applications that doesn't use
|
101
|
+
cookie-based sessions #275 [jcf]
|
102
|
+
|
103
|
+
* Fixed that cached template loading would still check the file system to see if the file existed #258 [Andreas Schwarz]
|
104
|
+
|
105
|
+
* Added options to tailor header tag, div id, and div class on ActiveRecordHelper#error_messages_for [josh]
|
106
|
+
|
107
|
+
* Added graceful handling of non-alphanumeric names and misplaced brackets in input parameters [bitsweat]
|
108
|
+
|
109
|
+
* Added a new container for cookies that makes them more intuative to use. The old methods of cookie and @cookies have been deprecated.
|
110
|
+
|
111
|
+
Examples for writing:
|
112
|
+
|
113
|
+
cookies["user_name"] = "david" # => Will set a simple session cookie
|
114
|
+
cookies["login"] = { "value" => "XJ-122", "expires" => Time.now + 360} # => Will set a cookie that expires in 1 hour
|
115
|
+
|
116
|
+
Examples for reading:
|
117
|
+
|
118
|
+
cookies["user_name"] # => "david"
|
119
|
+
cookies.size # => 2
|
120
|
+
|
121
|
+
Read more in ActionController::Cookies
|
122
|
+
|
123
|
+
NOTE: If you were using the old accessor (cookies instead of @cookies), this could potentially break your code -- if you expect a full cookie object!
|
124
|
+
|
125
|
+
* Added the opportunity to defined method_missing on a controller which will handle all requests for actions not otherwise defined #223 [timb]
|
126
|
+
|
127
|
+
* Fixed AbstractRequest#remote_ip for users going through proxies - Patch #228 [Eric Hodel]
|
128
|
+
|
129
|
+
* Added Request#ssl? which is shorthand for @request.protocol == "https://"
|
130
|
+
|
131
|
+
* Added the choice to call form_tag with no arguments (resulting in a form posting to current action) [bitsweat]
|
132
|
+
|
133
|
+
* Upgraded to Builder 1.2.1
|
134
|
+
|
135
|
+
* Added :module as an alias for :controller_prefix to url_for and friends, so you can do redirect_to(:module => "shop", :controller => "purchases")
|
136
|
+
and go to /shop/purchases/
|
137
|
+
|
138
|
+
* Added support for controllers in modules through @params["module"].
|
139
|
+
|
140
|
+
* Added reloading for dependencies under cached environments like FastCGI and mod_ruby. This makes it possible to use those environments for development.
|
141
|
+
This is turned on by default, but can be turned off with ActionController::Base.reload_dependencies = false in production environments.
|
142
|
+
|
143
|
+
NOTE: This will only have an effect if you use the new model, service, and observer class methods to mark dependencies. All libraries loaded through
|
144
|
+
require will be "forever" cached. You can, however, use ActionController::Base.load_or_require("library") to get this behavior outside of the new
|
145
|
+
dependency style.
|
146
|
+
|
147
|
+
* Added that controllers will automatically require their own helper if possible. So instead of doing:
|
148
|
+
|
149
|
+
class MsgController < ApplicationController
|
150
|
+
helper :msg
|
151
|
+
end
|
152
|
+
|
153
|
+
...you can just do:
|
154
|
+
|
155
|
+
class MsgController < ApplicationController
|
156
|
+
end
|
157
|
+
|
158
|
+
* Added dependencies_on(layer) to query the dependencies of a controller. Examples:
|
159
|
+
|
160
|
+
MsgController.dependencies_on(:model) # => [ :post, :comment, :attachment ]
|
161
|
+
MsgController.dependencies_on(:service) # => [ :notification_service ]
|
162
|
+
MsgController.dependencies_on(:observer) # => [ :comment_observer ]
|
163
|
+
|
164
|
+
* Added a new dependency model with the class methods model, service, and observer. Example:
|
165
|
+
|
166
|
+
class MsgController < ApplicationController
|
167
|
+
model :post, :comment, :attachment
|
168
|
+
service :notification_service
|
169
|
+
observer :comment_observer
|
170
|
+
end
|
171
|
+
|
172
|
+
These new "keywords" remove the need for explicitly calling 'require' in most cases. The observer method even instantiates the
|
173
|
+
observer as well as requiring it.
|
174
|
+
|
175
|
+
* Fixed that link_to would escape & in the url again after url_for already had done so
|
176
|
+
|
177
|
+
|
1
178
|
*0.9.5* (28)
|
2
179
|
|
3
180
|
* Added helper_method to designate that a given private or protected method you should available as a helper in the view. [bitsweat]
|
data/README
CHANGED
data/install.rb
CHANGED
data/lib/action_controller.rb
CHANGED
@@ -24,6 +24,7 @@
|
|
24
24
|
$:.unshift(File.dirname(__FILE__))
|
25
25
|
|
26
26
|
require 'action_controller/support/clean_logger'
|
27
|
+
require 'action_controller/support/misc'
|
27
28
|
|
28
29
|
require 'action_controller/base'
|
29
30
|
require 'action_controller/rescue'
|
@@ -31,18 +32,22 @@ require 'action_controller/benchmarking'
|
|
31
32
|
require 'action_controller/filters'
|
32
33
|
require 'action_controller/layout'
|
33
34
|
require 'action_controller/flash'
|
35
|
+
require 'action_controller/dependencies'
|
34
36
|
require 'action_controller/scaffolding'
|
35
37
|
require 'action_controller/helpers'
|
38
|
+
require 'action_controller/cookies'
|
36
39
|
require 'action_controller/cgi_process'
|
37
40
|
|
38
41
|
ActionController::Base.class_eval do
|
39
42
|
include ActionController::Filters
|
40
43
|
include ActionController::Layout
|
41
44
|
include ActionController::Flash
|
42
|
-
include ActionController::Helpers
|
43
45
|
include ActionController::Benchmarking
|
44
46
|
include ActionController::Rescue
|
47
|
+
include ActionController::Dependencies
|
45
48
|
include ActionController::Scaffolding
|
49
|
+
include ActionController::Helpers
|
50
|
+
include ActionController::Cookies
|
46
51
|
end
|
47
52
|
|
48
53
|
require 'action_view'
|
@@ -22,7 +22,7 @@ module Test #:nodoc:
|
|
22
22
|
# Assert the template object with the given name is an Active Record descendant and the specified column(s) are valid.
|
23
23
|
def assert_valid_column_on_record(key = nil, columns = "", message = nil)
|
24
24
|
record = find_record_in_template(key)
|
25
|
-
record.validate
|
25
|
+
record.send(:validate)
|
26
26
|
|
27
27
|
cols = glue_columns(columns)
|
28
28
|
cols.delete_if { |col| !record.errors.invalid?(col) }
|
@@ -33,7 +33,7 @@ module Test #:nodoc:
|
|
33
33
|
# Assert the template object with the given name is an Active Record descendant and the specified column(s) are invalid.
|
34
34
|
def assert_invalid_column_on_record(key = nil, columns = "", message = nil)
|
35
35
|
record = find_record_in_template(key)
|
36
|
-
record.validate
|
36
|
+
record.send(:validate)
|
37
37
|
|
38
38
|
cols = glue_columns(columns)
|
39
39
|
cols.delete_if { |col| record.errors.invalid?(col) }
|
@@ -58,7 +58,7 @@ module ActionController #:nodoc:
|
|
58
58
|
# accessing the environment hash, like this:
|
59
59
|
#
|
60
60
|
# def hello_ip
|
61
|
-
# location = @request.env["
|
61
|
+
# location = @request.env["REMOTE_IP"]
|
62
62
|
# render_text "Hello stranger from #{location}"
|
63
63
|
# end
|
64
64
|
#
|
@@ -175,9 +175,10 @@ module ActionController #:nodoc:
|
|
175
175
|
DEFAULT_RENDER_STATUS_CODE = "200 OK"
|
176
176
|
|
177
177
|
DEFAULT_SEND_FILE_OPTIONS = {
|
178
|
-
:type
|
178
|
+
:type => 'application/octet_stream',
|
179
179
|
:disposition => 'attachment',
|
180
|
-
:stream
|
180
|
+
:stream => true,
|
181
|
+
:buffer_size => 4096
|
181
182
|
}
|
182
183
|
|
183
184
|
|
@@ -228,10 +229,6 @@ module ActionController #:nodoc:
|
|
228
229
|
# directive. Values should always be specified as strings.
|
229
230
|
attr_accessor :headers
|
230
231
|
|
231
|
-
# Holds a hash of cookie names and values. Accessed like <tt>@cookies["user_name"]</tt> to get the value of the user_name cookie.
|
232
|
-
# This hash is read-only. You set new cookies using the cookie method.
|
233
|
-
attr_accessor :cookies
|
234
|
-
|
235
232
|
# Holds the hash of variables that are passed on to the template class to be made available to the view. This hash
|
236
233
|
# is generated by taking a snapshot of all the instance variables in the current scope just before a template is rendered.
|
237
234
|
attr_accessor :assigns
|
@@ -241,17 +238,27 @@ module ActionController #:nodoc:
|
|
241
238
|
def process(request, response) #:nodoc:
|
242
239
|
new.process(request, response)
|
243
240
|
end
|
241
|
+
|
242
|
+
# Converts the class name from something like "OneModule::TwoModule::NeatController" to "NeatController".
|
243
|
+
def controller_class_name
|
244
|
+
Inflector.demodulize(name)
|
245
|
+
end
|
246
|
+
|
247
|
+
# Converts the class name from something like "OneModule::TwoModule::NeatController" to "neat".
|
248
|
+
def controller_name
|
249
|
+
Inflector.underscore(controller_class_name.sub(/Controller/, ""))
|
250
|
+
end
|
244
251
|
end
|
245
252
|
|
246
253
|
public
|
247
254
|
# Extracts the action_name from the request parameters and performs that action.
|
248
|
-
def process(request, response) #:nodoc:
|
255
|
+
def process(request, response, method = :perform_action, *arguments) #:nodoc:
|
249
256
|
initialize_template_class(response)
|
250
257
|
assign_shortcuts(request, response)
|
251
258
|
initialize_current_url
|
252
259
|
|
253
260
|
log_processing unless logger.nil?
|
254
|
-
|
261
|
+
send(method, *arguments)
|
255
262
|
close_session
|
256
263
|
|
257
264
|
return @response
|
@@ -264,10 +271,11 @@ module ActionController #:nodoc:
|
|
264
271
|
# .---> controller .--> action
|
265
272
|
# /library/books/ISBN/0743536703/show
|
266
273
|
# '------> '--------------> action_prefix
|
267
|
-
# controller_prefix
|
274
|
+
# controller_prefix (or module)
|
268
275
|
#
|
269
276
|
# * <tt>:controller_prefix</tt> - specifies the string before the controller name, which would be "/library" for the example.
|
270
277
|
# Called with "/shop" gives "/shop/books/ISBN/0743536703/show".
|
278
|
+
# * <tt>:module</tt> - serves as a alias to :controller_prefix (overwrites :controller_prefix unless its nil)
|
271
279
|
# * <tt>:controller</tt> - specifies a new controller and clears out everything after the controller name (including the action,
|
272
280
|
# the pre- and suffix, and all params), so called with "settings" gives "/library/settings/".
|
273
281
|
# * <tt>:action_prefix</tt> - specifies the string between the controller name and the action name, which would
|
@@ -290,6 +298,7 @@ module ActionController #:nodoc:
|
|
290
298
|
# Naturally, you can combine multiple options in a single redirect. Examples:
|
291
299
|
#
|
292
300
|
# redirect_to(:controller_prefix => "/shop", :controller => "settings")
|
301
|
+
# redirect_to(:controller_prefix => false, :controller => "settings") # breaks out of the current controller_prefix
|
293
302
|
# redirect_to(:action => "edit", :id => 3425)
|
294
303
|
# redirect_to(:action => "edit", :path_params => { "type" => "XTC" }, :params => { "temp" => 1})
|
295
304
|
# redirect_to(:action => "publish", :action_prefix => "/published", :anchor => "x14")
|
@@ -315,14 +324,18 @@ module ActionController #:nodoc:
|
|
315
324
|
end
|
316
325
|
end
|
317
326
|
|
327
|
+
def module_name
|
328
|
+
@params["module"]
|
329
|
+
end
|
330
|
+
|
318
331
|
# Converts the class name from something like "OneModule::TwoModule::NeatController" to "NeatController".
|
319
332
|
def controller_class_name
|
320
|
-
self.class.
|
333
|
+
self.class.controller_class_name
|
321
334
|
end
|
322
335
|
|
323
336
|
# Converts the class name from something like "OneModule::TwoModule::NeatController" to "neat".
|
324
337
|
def controller_name
|
325
|
-
|
338
|
+
self.class.controller_name
|
326
339
|
end
|
327
340
|
|
328
341
|
# Returns the name of the action this controller is processing.
|
@@ -337,14 +350,14 @@ module ActionController #:nodoc:
|
|
337
350
|
# shared by all controllers. It's also possible to pass a status code using the second parameter. This defaults to "200 OK",
|
338
351
|
# but can be changed, such as by calling <tt>render("weblog/error", "500 Error")</tt>.
|
339
352
|
def render(template_name = nil, status = nil) #:doc:
|
340
|
-
render_file(template_name ||
|
353
|
+
render_file(template_name || default_template_name, status, true)
|
341
354
|
end
|
342
355
|
|
343
356
|
# Works like render, but instead of requiring a full template name, you can get by with specifying the action name. So calling
|
344
357
|
# <tt>render_action "show_many"</tt> in WeblogController#display will render "#{template_root}/weblog/show_many.rhtml" or
|
345
358
|
# "#{template_root}/weblog/show_many.rxml".
|
346
359
|
def render_action(action_name, status = nil) #:doc:
|
347
|
-
render
|
360
|
+
render default_template_name(action_name), status
|
348
361
|
end
|
349
362
|
|
350
363
|
# Works like render, but disregards the template_root and requires a full path to the template that needs to be rendered. Can be
|
@@ -430,11 +443,17 @@ module ActionController #:nodoc:
|
|
430
443
|
logger.info "Streaming file #{path}" unless logger.nil?
|
431
444
|
len = options[:buffer_size] || 4096
|
432
445
|
File.open(path, 'rb') do |file|
|
433
|
-
|
434
|
-
|
435
|
-
|
446
|
+
if $stdout.respond_to?(:syswrite)
|
447
|
+
begin
|
448
|
+
while true
|
449
|
+
$stdout.syswrite file.sysread(len)
|
450
|
+
end
|
451
|
+
rescue EOFError
|
452
|
+
end
|
453
|
+
else
|
454
|
+
while buf = file.read(len)
|
455
|
+
$stdout.write buf
|
436
456
|
end
|
437
|
-
rescue EOFError
|
438
457
|
end
|
439
458
|
end
|
440
459
|
end
|
@@ -517,22 +536,6 @@ module ActionController #:nodoc:
|
|
517
536
|
@performed_redirect = true
|
518
537
|
end
|
519
538
|
|
520
|
-
# Creates a new cookie that is sent along-side the next render or redirect command. API is the same as for CGI::Cookie.
|
521
|
-
# Examples:
|
522
|
-
#
|
523
|
-
# cookie("name", "value1", "value2", ...)
|
524
|
-
# cookie("name" => "name", "value" => "value")
|
525
|
-
# cookie('name' => 'name',
|
526
|
-
# 'value' => ['value1', 'value2', ...],
|
527
|
-
# 'path' => 'path', # optional
|
528
|
-
# 'domain' => 'domain', # optional
|
529
|
-
# 'expires' => Time.now, # optional
|
530
|
-
# 'secure' => true # optional
|
531
|
-
# )
|
532
|
-
def cookie(*options) #:doc:
|
533
|
-
@response.headers["cookie"] << CGI::Cookie.new(*options)
|
534
|
-
end
|
535
|
-
|
536
539
|
# Resets the session by clearsing out all the objects stored within and initializing a new session object.
|
537
540
|
def reset_session #:doc:
|
538
541
|
@request.reset_session
|
@@ -540,6 +543,11 @@ module ActionController #:nodoc:
|
|
540
543
|
@response.session = @session
|
541
544
|
end
|
542
545
|
|
546
|
+
# Deprecated cookie writer method
|
547
|
+
def cookie(*options)
|
548
|
+
@response.headers["cookie"] << CGI::Cookie.new(*options)
|
549
|
+
end
|
550
|
+
|
543
551
|
private
|
544
552
|
def initialize_template_class(response)
|
545
553
|
begin
|
@@ -573,7 +581,7 @@ module ActionController #:nodoc:
|
|
573
581
|
end
|
574
582
|
|
575
583
|
def perform_action
|
576
|
-
if action_methods.include?(action_name)
|
584
|
+
if action_methods.include?(action_name) || action_methods.include?('method_missing')
|
577
585
|
send(action_name)
|
578
586
|
render unless @performed_render || @performed_redirect
|
579
587
|
elsif template_exists? && template_public?
|
@@ -620,14 +628,14 @@ module ActionController #:nodoc:
|
|
620
628
|
end
|
621
629
|
|
622
630
|
def close_session
|
623
|
-
@session.close
|
631
|
+
@session.close unless @session.nil? || Hash === @session
|
624
632
|
end
|
625
633
|
|
626
|
-
def template_exists?(template_name =
|
634
|
+
def template_exists?(template_name = default_template_name)
|
627
635
|
@template.file_exists?(template_name)
|
628
636
|
end
|
629
637
|
|
630
|
-
def template_public?(template_name =
|
638
|
+
def template_public?(template_name = default_template_name)
|
631
639
|
@template.file_public?(template_name)
|
632
640
|
end
|
633
641
|
|
@@ -649,11 +657,15 @@ module ActionController #:nodoc:
|
|
649
657
|
disposition <<= %(; filename="#{options[:filename]}") if options[:filename]
|
650
658
|
|
651
659
|
@headers.update(
|
652
|
-
'Content-Length'
|
653
|
-
'Content-Type'
|
654
|
-
'Content-Disposition'
|
660
|
+
'Content-Length' => options[:length],
|
661
|
+
'Content-Type' => options[:type],
|
662
|
+
'Content-Disposition' => disposition,
|
655
663
|
'Content-Transfer-Encoding' => 'binary'
|
656
664
|
);
|
657
665
|
end
|
666
|
+
|
667
|
+
def default_template_name(default_action_name = action_name)
|
668
|
+
module_name ? "#{module_name}/#{controller_name}/#{default_action_name}" : "#{controller_name}/#{default_action_name}"
|
669
|
+
end
|
658
670
|
end
|
659
671
|
end
|