aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/renderer/partial_renderer.rb
diff options
context:
space:
mode:
authorAngelo capilleri <capilleri@yahoo.com>2013-06-25 12:27:50 +0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-12-29 20:59:57 -0300
commitc85fed05c531d4d148333613e03ceb0ada061be0 (patch)
tree2ca40453d6891195b7a84c7d9ce2aba338ac8b65 /actionview/lib/action_view/renderer/partial_renderer.rb
parentc0329b3d4961b7978738663dd75f03edd7d69811 (diff)
downloadrails-c85fed05c531d4d148333613e03ceb0ada061be0.tar.gz
rails-c85fed05c531d4d148333613e03ceb0ada061be0.tar.bz2
rails-c85fed05c531d4d148333613e03ceb0ada061be0.zip
fix error message of option as with invalid charters in partial rendering
before this PR IDENTIFIER_ERROR_MESSAGE could lead to misunderstand the convention of partial name. Added OPTION_AS_ERROR_MESSAGE for unvalid charter in as option.
Diffstat (limited to 'actionview/lib/action_view/renderer/partial_renderer.rb')
-rw-r--r--actionview/lib/action_view/renderer/partial_renderer.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/actionview/lib/action_view/renderer/partial_renderer.rb b/actionview/lib/action_view/renderer/partial_renderer.rb
index f627d5d40c..610396506f 100644
--- a/actionview/lib/action_view/renderer/partial_renderer.rb
+++ b/actionview/lib/action_view/renderer/partial_renderer.rb
@@ -384,7 +384,7 @@ module ActionView
end
if as = options[:as]
- raise_invalid_identifier(as) unless as.to_s =~ /\A[a-z_]\w*\z/
+ raise_invalid_option_as(as) unless as.to_s =~ /\A[a-z_]\w*\z/
as = as.to_sym
end
@@ -530,11 +530,19 @@ module ActionView
end
IDENTIFIER_ERROR_MESSAGE = "The partial name (%s) is not a valid Ruby identifier; " +
- "make sure your partial name starts with a lowercase letter or underscore, " +
+ "make sure your partial name starts with underscore, " +
+ "and is followed by any combination of letters, numbers and underscores."
+
+ OPTION_AS_ERROR_MESSAGE = "The value (%s) of the option `as` is not a valid Ruby identifier; " +
+ "make sure it starts with lowercase letter, " +
"and is followed by any combination of letters, numbers and underscores."
def raise_invalid_identifier(path)
raise ArgumentError.new(IDENTIFIER_ERROR_MESSAGE % (path))
end
+
+ def raise_invalid_option_as(as)
+ raise ArgumentError.new(OPTION_AS_ERROR_MESSAGE % (as))
+ end
end
end