aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/vendor/html-scanner/html/node.rb4
-rw-r--r--actionpack/lib/action_dispatch/railtie.rb5
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb16
-rw-r--r--actionpack/lib/action_view.rb35
-rw-r--r--actionpack/lib/action_view/base.rb5
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb10
-rw-r--r--actionpack/lib/action_view/helpers/prototype_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/url_helper.rb9
8 files changed, 40 insertions, 46 deletions
diff --git a/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb b/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb
index d581399514..0eaad2b911 100644
--- a/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb
+++ b/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb
@@ -77,9 +77,7 @@ module HTML #:nodoc:
# Return a textual representation of the node.
def to_s
- s = ""
- @children.each { |child| s << child.to_s }
- s
+ @children.join()
end
# Return false (subclasses must override this to provide specific matching
diff --git a/actionpack/lib/action_dispatch/railtie.rb b/actionpack/lib/action_dispatch/railtie.rb
index a3af37947a..ed066ad75e 100644
--- a/actionpack/lib/action_dispatch/railtie.rb
+++ b/actionpack/lib/action_dispatch/railtie.rb
@@ -8,10 +8,5 @@ module ActionDispatch
config.action_dispatch.ip_spoofing_check = true
config.action_dispatch.show_exceptions = true
config.action_dispatch.best_standards_support = true
-
- # Prepare dispatcher callbacks and run 'prepare' callbacks
- initializer "action_dispatch.prepare_dispatcher" do |app|
- ActionDispatch::Callbacks.to_prepare { app.routes_reloader.execute_if_updated }
- end
end
end
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index a3bd4771c2..a2570cb877 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -909,6 +909,11 @@ module ActionDispatch
return true
end
+ if resource_scope?
+ nested { send(method, resources.pop, options, &block) }
+ return true
+ end
+
options.keys.each do |k|
(options[:constraints] ||= {})[k] = options.delete(k) if options[k].is_a?(Regexp)
end
@@ -925,13 +930,6 @@ module ActionDispatch
options.merge!(scope_action_options) if scope_action_options?
end
- if resource_scope?
- nested do
- send(method, resources.pop, options, &block)
- end
- return true
- end
-
false
end
@@ -1017,11 +1015,11 @@ module ActionDispatch
end
def id_constraint?
- @scope[:id].is_a?(Regexp) || (@scope[:constraints] && @scope[:constraints][:id].is_a?(Regexp))
+ @scope[:constraints] && @scope[:constraints][:id].is_a?(Regexp)
end
def id_constraint
- @scope[:id] || @scope[:constraints][:id]
+ @scope[:constraints][:id]
end
def canonical_action?(action, flag)
diff --git a/actionpack/lib/action_view.rb b/actionpack/lib/action_view.rb
index c0d7423682..5f9dc70766 100644
--- a/actionpack/lib/action_view.rb
+++ b/actionpack/lib/action_view.rb
@@ -36,6 +36,10 @@ module ActionView
autoload :Context
autoload :Template
autoload :Helpers
+ autoload :Base
+ autoload :LookupContext
+ autoload :PathSet, "action_view/paths"
+ autoload :TestCase, "action_view/test_case"
autoload_under "render" do
autoload :Layouts
@@ -43,25 +47,26 @@ module ActionView
autoload :Rendering
end
- autoload :Base
- autoload :LookupContext
- autoload :Resolver, 'action_view/template/resolver'
- autoload :PathResolver, 'action_view/template/resolver'
- autoload :FileSystemResolver, 'action_view/template/resolver'
- autoload :PathSet, 'action_view/paths'
+ autoload_at "action_view/template/resolver" do
+ autoload :Resolver
+ autoload :PathResolver
+ autoload :FileSystemResolver
+ end
- autoload :MissingTemplate, 'action_view/template/error'
- autoload :ActionViewError, 'action_view/template/error'
- autoload :EncodingError, 'action_view/template/error'
- autoload :TemplateError, 'action_view/template/error'
- autoload :WrongEncodingError, 'action_view/template/error'
+ autoload_at "action_view/template/error" do
+ autoload :MissingTemplate
+ autoload :ActionViewError
+ autoload :EncodingError
+ autoload :TemplateError
+ autoload :WrongEncodingError
+ end
- autoload :TemplateHandler, 'action_view/template'
- autoload :TemplateHandlers, 'action_view/template'
+ autoload_at "action_view/template" do
+ autoload :TemplateHandler
+ autoload :TemplateHandlers
+ end
end
- autoload :TestCase, 'action_view/test_case'
-
ENCODING_FLAG = '#.*coding[:=]\s*(\S+)[ \t]*'
end
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index ff25c36fcd..b0a57f47d3 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -188,11 +188,6 @@ module ActionView #:nodoc:
delegate :logger, :to => :controller, :allow_nil => true
- # TODO: HACK FOR RJS
- def view_context
- self
- end
-
def self.xss_safe? #:nodoc:
true
end
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 6c3d2cf1b8..94dc25eb85 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -202,6 +202,12 @@ module ActionView
# ...
# <% end %>
#
+ # You can also set the answer format, like this:
+ #
+ # <%= form_for(@post, :format => :json) do |f| %>
+ # ...
+ # <% end %>
+ #
# If you have an object that needs to be represented as a different
# parameter, like a Client that acts as a Person:
#
@@ -332,7 +338,9 @@ module ActionView
options[:html] ||= {}
options[:html].reverse_merge!(html_options)
- options[:url] ||= polymorphic_path(object_or_array)
+ options[:url] ||= options[:format] ? \
+ polymorphic_path(object_or_array, :format => options.delete(:format)) : \
+ polymorphic_path(object_or_array)
end
# Creates a scope around a specific model object like form_for, but
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index 99f9363a9a..b600666536 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -579,7 +579,7 @@ module ActionView
# page.hide 'spinner'
# end
def update_page(&block)
- JavaScriptGenerator.new(view_context, &block).to_s.html_safe
+ JavaScriptGenerator.new(self, &block).to_s.html_safe
end
# Works like update_page but wraps the generated JavaScript in a <script>
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb
index 4f14bfe221..b8df2d9a69 100644
--- a/actionpack/lib/action_view/helpers/url_helper.rb
+++ b/actionpack/lib/action_view/helpers/url_helper.rb
@@ -235,13 +235,8 @@ module ActionView
html_options = convert_options_to_data_attributes(options, html_options)
url = url_for(options)
- if html_options
- html_options = html_options.stringify_keys
- href = html_options['href']
- tag_options = tag_options(html_options)
- else
- tag_options = nil
- end
+ href = html_options['href']
+ tag_options = tag_options(html_options)
href_attr = "href=\"#{html_escape(url)}\"" unless href
"<a #{href_attr}#{tag_options}>#{html_escape(name || url)}</a>".html_safe