aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/abstract_controller/base.rb2
-rw-r--r--actionpack/lib/abstract_controller/view_paths.rb3
-rw-r--r--actionpack/lib/action_controller/caching/sweeping.rb1
-rw-r--r--actionpack/lib/action_controller/metal/hide_actions.rb6
-rw-r--r--actionpack/lib/action_dispatch/middleware/show_exceptions.rb2
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb37
-rw-r--r--actionpack/lib/action_view/base.rb23
-rw-r--r--actionpack/lib/action_view/helpers/text_helper.rb83
-rw-r--r--actionpack/lib/action_view/test_case.rb14
9 files changed, 34 insertions, 137 deletions
diff --git a/actionpack/lib/abstract_controller/base.rb b/actionpack/lib/abstract_controller/base.rb
index ff97a7e76a..e1027840ef 100644
--- a/actionpack/lib/abstract_controller/base.rb
+++ b/actionpack/lib/abstract_controller/base.rb
@@ -106,7 +106,7 @@ module AbstractController
@_action_name = action_name = action.to_s
unless action_name = method_for_action(action_name)
- raise ActionNotFound, "The action '#{action}' could not be found"
+ raise ActionNotFound, "The action '#{action}' could not be found for #{self.class.name}"
end
@_response_body = nil
diff --git a/actionpack/lib/abstract_controller/view_paths.rb b/actionpack/lib/abstract_controller/view_paths.rb
index b331eb51b6..b552a649d1 100644
--- a/actionpack/lib/abstract_controller/view_paths.rb
+++ b/actionpack/lib/abstract_controller/view_paths.rb
@@ -5,6 +5,7 @@ module AbstractController
included do
class_attribute :_view_paths
self._view_paths = ActionView::PathSet.new
+ self._view_paths.freeze
end
delegate :find_template, :template_exists?, :view_paths, :formats, :formats=,
@@ -61,7 +62,7 @@ module AbstractController
# paths<ViewPathSet, Object>:: If a ViewPathSet is provided, use that;
# otherwise, process the parameter into a ViewPathSet.
def view_paths=(paths)
- self._view_paths = paths.is_a?(ActionView::PathSet) ? paths : ActionView::Base.process_view_paths(paths)
+ self._view_paths = ActionView::Base.process_view_paths(paths)
self._view_paths.freeze
end
end
diff --git a/actionpack/lib/action_controller/caching/sweeping.rb b/actionpack/lib/action_controller/caching/sweeping.rb
index cf16417e84..e9db0d97b6 100644
--- a/actionpack/lib/action_controller/caching/sweeping.rb
+++ b/actionpack/lib/action_controller/caching/sweeping.rb
@@ -57,6 +57,7 @@ module ActionController #:nodoc:
def before(controller)
self.controller = controller
callback(:before) if controller.perform_caching
+ true # before method from sweeper should always return true
end
def after(controller)
diff --git a/actionpack/lib/action_controller/metal/hide_actions.rb b/actionpack/lib/action_controller/metal/hide_actions.rb
index 3358d80c35..32d7a96701 100644
--- a/actionpack/lib/action_controller/metal/hide_actions.rb
+++ b/actionpack/lib/action_controller/metal/hide_actions.rb
@@ -8,7 +8,7 @@ module ActionController
included do
class_attribute :hidden_actions
- self.hidden_actions = Set.new
+ self.hidden_actions = Set.new.freeze
end
private
@@ -25,7 +25,7 @@ module ActionController
# ==== Parameters
# *args<#to_s>:: A list of actions
def hide_action(*args)
- self.hidden_actions = hidden_actions.dup.merge(args.map(&:to_s))
+ self.hidden_actions = hidden_actions.dup.merge(args.map(&:to_s)).freeze
end
def inherited(klass)
@@ -41,7 +41,7 @@ module ActionController
# Overrides AbstractController::Base#action_methods to remove any methods
# that are listed as hidden methods.
def action_methods
- @action_methods ||= Set.new(super.reject {|name| hidden_actions.include?(name)})
+ @action_methods ||= Set.new(super.reject { |name| hidden_actions.include?(name) })
end
end
end
diff --git a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
index 8a2d8cd077..0a6d2bfc8a 100644
--- a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
+++ b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
@@ -135,7 +135,7 @@ module ActionDispatch
ActiveSupport::Deprecation.silence do
message = "\n#{exception.class} (#{exception.message}):\n"
message << exception.annoted_source_code if exception.respond_to?(:annoted_source_code)
- message << exception.backtrace.join("\n ")
+ message << " " << application_trace(exception).join("\n ")
logger.fatal("#{message}\n\n")
end
end
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index e91a72cbe5..7b79b6bde3 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -350,10 +350,6 @@ module ActionDispatch
scope(:constraints => constraints) { yield }
end
- def shallow
- scope(:shallow => true) { yield }
- end
-
def defaults(defaults = {})
scope(:defaults => defaults) { yield }
end
@@ -378,21 +374,12 @@ module ActionDispatch
@scope_options ||= private_methods.grep(/^merge_(.+)_scope$/) { $1.to_sym }
end
- def merge_shallow_scope(parent, child)
- parent or child
- end
-
def merge_path_scope(parent, child)
- parent_path = (@scope[:shallow] and child.eql?(':id')) ? parent.split('/').last : parent
- Mapper.normalize_path "#{parent_path}/#{child}"
+ Mapper.normalize_path("#{parent}/#{child}")
end
def merge_name_prefix_scope(parent, child)
- if @scope[:shallow]
- child
- else
- parent ? "#{parent}_#{child}" : child
- end
+ parent ? "#{parent}_#{child}" : child
end
def merge_module_scope(parent, child)
@@ -535,10 +522,6 @@ module ActionDispatch
options["#{singular}_id".to_sym] = id_constraint if id_constraint?
options
end
-
- def shallow?
- options[:shallow]
- end
end
class SingletonResource < Resource #:nodoc:
@@ -620,12 +603,8 @@ module ActionDispatch
resource = Resource.new(resources.pop, options)
- scope(:path => resource.path, :controller => resource.controller, :shallow => resource.shallow?) do
+ scope(:path => resource.path, :controller => resource.controller) do
with_scope_level(:resources, resource) do
- if @scope[:shallow] && @scope[:name_prefix]
- @scope[:path] = "/#{@scope[:name_prefix].pluralize}/:#{@scope[:name_prefix]}_id/#{resource.path}"
- end
-
yield if block_given?
with_scope_level(:collection) do
@@ -639,8 +618,6 @@ module ActionDispatch
with_scope_level(:member) do
scope(':id') do
scope(resource.options) do
- @scope[:name_prefix] = nil if @scope[:shallow]
-
get :show if resource.actions.include?(:show)
put :update if resource.actions.include?(:update)
delete :destroy if resource.actions.include?(:destroy)
@@ -702,6 +679,14 @@ module ActionDispatch
end
end
+ def namespace(path)
+ if resource_scope?
+ nested { super }
+ else
+ super
+ end
+ end
+
def match(*args)
options = args.extract_options!
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index 7dd9dea358..5fa1b5619b 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -158,7 +158,6 @@ module ActionView #:nodoc:
end
include Helpers, Rendering, Partials, Layouts, ::ERB::Util, Context
- extend ActiveSupport::Memoizable
# Specify whether RJS responses should be wrapped in a try/catch block
# that alert()s the caught exception (and then re-raises it).
@@ -170,9 +169,6 @@ module ActionView #:nodoc:
@@field_error_proc = Proc.new{ |html_tag, instance| "<div class=\"field_with_errors\">#{html_tag}</div>".html_safe }
class_attribute :helpers
- remove_method :helpers
- attr_reader :helpers
-
class_attribute :_router
class << self
@@ -201,20 +197,21 @@ module ActionView #:nodoc:
end
def self.process_view_paths(value)
- return value.dup if value.is_a?(PathSet)
- ActionView::PathSet.new(Array.wrap(value))
+ value.is_a?(PathSet) ?
+ value.dup : ActionView::PathSet.new(Array.wrap(value))
end
def initialize(lookup_context = nil, assigns_for_first_render = {}, controller = nil, formats = nil) #:nodoc:
- @config = nil
- @assigns = assigns_for_first_render.each { |key, value| instance_variable_set("@#{key}", value) }
- @helpers = self.class.helpers || Module.new
+ self.assigns = assigns_for_first_render.each { |key, value| instance_variable_set("@#{key}", value) }
+ self.helpers = self.class.helpers || Module.new
if @_controller = controller
@_request = controller.request if controller.respond_to?(:request)
end
- @_config = ActiveSupport::InheritableOptions.new(controller.config) if controller && controller.respond_to?(:config)
+ config = controller && controller.respond_to?(:config) ? controller.config : {}
+ @_config = ActiveSupport::InheritableOptions.new(config)
+
@_content_for = Hash.new { |h,k| h[k] = ActiveSupport::SafeBuffer.new }
@_virtual_path = nil
@output_buffer = nil
@@ -228,12 +225,6 @@ module ActionView #:nodoc:
@controller_path ||= controller && controller.controller_path
end
- def punctuate_body!(part)
- flush_output_buffer
- response.body_parts << part
- nil
- end
-
ActiveSupport.run_load_hooks(:action_view, self)
end
end
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb
index 8f63845d49..a06073ce66 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -220,89 +220,6 @@ module ActionView
end * "\n"
end
- # Returns the text with all the Textile[http://www.textism.com/tools/textile] codes turned into HTML tags.
- #
- # You can learn more about Textile's syntax at its website[http://www.textism.com/tools/textile].
- # <i>This method is only available if RedCloth[http://redcloth.org/] is available</i>.
- #
- # ==== Examples
- # textilize("*This is Textile!* Rejoice!")
- # # => "<p><strong>This is Textile!</strong> Rejoice!</p>"
- #
- # textilize("I _love_ ROR(Ruby on Rails)!")
- # # => "<p>I <em>love</em> <acronym title="Ruby on Rails">ROR</acronym>!</p>"
- #
- # textilize("h2. Textile makes markup -easy- simple!")
- # # => "<h2>Textile makes markup <del>easy</del> simple!</h2>"
- #
- # textilize("Visit the Rails website "here":http://www.rubyonrails.org/.)
- # # => "<p>Visit the Rails website <a href="http://www.rubyonrails.org/">here</a>.</p>"
- #
- # textilize("This is worded <strong>strongly</strong>")
- # # => "<p>This is worded <strong>strongly</strong></p>"
- #
- # textilize("This is worded <strong>strongly</strong>", :filter_html)
- # # => "<p>This is worded &lt;strong&gt;strongly&lt;/strong&gt;</p>"
- #
- def textilize(text, *options)
- options ||= [:hard_breaks]
- text = sanitize(text) unless text.html_safe? || options.delete(:safe)
-
- if text.blank?
- ""
- else
- textilized = RedCloth.new(text, options)
- textilized.to_html
- end.html_safe
- end
-
- # Returns the text with all the Textile codes turned into HTML tags,
- # but without the bounding <p> tag that RedCloth adds.
- #
- # You can learn more about Textile's syntax at its website[http://www.textism.com/tools/textile].
- # <i>This method is only available if RedCloth[http://redcloth.org/] is available</i>.
- #
- # ==== Examples
- # textilize_without_paragraph("*This is Textile!* Rejoice!")
- # # => "<strong>This is Textile!</strong> Rejoice!"
- #
- # textilize_without_paragraph("I _love_ ROR(Ruby on Rails)!")
- # # => "I <em>love</em> <acronym title="Ruby on Rails">ROR</acronym>!"
- #
- # textilize_without_paragraph("h2. Textile makes markup -easy- simple!")
- # # => "<h2>Textile makes markup <del>easy</del> simple!</h2>"
- #
- # textilize_without_paragraph("Visit the Rails website "here":http://www.rubyonrails.org/.)
- # # => "Visit the Rails website <a href="http://www.rubyonrails.org/">here</a>."
- def textilize_without_paragraph(text, *options)
- textiled = textilize(text, *options)
- if textiled[0..2] == "<p>" then textiled = textiled[3..-1] end
- if textiled[-4..-1] == "</p>" then textiled = textiled[0..-5] end
- return textiled
- end
-
- # Returns the text with all the Markdown codes turned into HTML tags.
- # <i>This method requires BlueCloth[http://www.deveiate.org/projects/BlueCloth]
- # to be available</i>.
- #
- # ==== Examples
- # markdown("We are using __Markdown__ now!")
- # # => "<p>We are using <strong>Markdown</strong> now!</p>"
- #
- # markdown("We like to _write_ `code`, not just _read_ it!")
- # # => "<p>We like to <em>write</em> <code>code</code>, not just <em>read</em> it!</p>"
- #
- # markdown("The [Markdown website](http://daringfireball.net/projects/markdown/) has more information.")
- # # => "<p>The <a href="http://daringfireball.net/projects/markdown/">Markdown website</a>
- # # has more information.</p>"
- #
- # markdown('![The ROR logo](http://rubyonrails.com/images/rails.png "Ruby on Rails")')
- # # => '<p><img src="http://rubyonrails.com/images/rails.png" alt="The ROR logo" title="Ruby on Rails" /></p>'
- def markdown(text, *options)
- text = sanitize(text) unless text.html_safe? || options.delete(:safe)
- (text.blank? ? "" : BlueCloth.new(text).to_html).html_safe
- end
-
# Returns +text+ transformed into HTML using simple formatting rules.
# Two or more consecutive newlines(<tt>\n\n</tt>) are considered as a
# paragraph and wrapped in <tt><p></tt> tags. One newline (<tt>\n</tt>) is
diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb
index 4dbbd2eb6a..15d424be74 100644
--- a/actionpack/lib/action_view/test_case.rb
+++ b/actionpack/lib/action_view/test_case.rb
@@ -131,12 +131,14 @@ module ActionView
end
def _view
- view = ActionView::Base.new(ActionController::Base.view_paths, _assigns, @controller)
- view.singleton_class.send :include, _helpers
- view.singleton_class.send :include, @controller._router.url_helpers
- view.singleton_class.send :delegate, :alert, :notice, :to => "request.flash"
- view.output_buffer = self.output_buffer
- view
+ @_view ||= begin
+ view = ActionView::Base.new(ActionController::Base.view_paths, _assigns, @controller)
+ view.singleton_class.send :include, _helpers
+ view.singleton_class.send :include, @controller._router.url_helpers
+ view.singleton_class.send :delegate, :alert, :notice, :to => "request.flash"
+ view.output_buffer = self.output_buffer
+ view
+ end
end
EXCLUDE_IVARS = %w{